< Summary

Line coverage
98%
Covered lines: 1298
Uncovered lines: 22
Coverable lines: 1320
Total lines: 4036
Line coverage: 98.3%
Branch coverage
80%
Covered branches: 157
Total branches: 196
Branch coverage: 80.1%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
File 1: Authenticate(...)100%11100%
File 1: <AuthenticateAsync()100%11100%
File 1: AuthEnable(...)100%11100%
File 1: <AuthEnableAsync()100%11100%
File 1: AuthDisable(...)100%11100%
File 1: <AuthDisableAsync()100%11100%
File 1: UserAdd(...)100%11100%
File 1: <UserAddAsync()100%11100%
File 1: UserGet(...)100%11100%
File 1: <UserGetAsync()100%11100%
File 1: UserList(...)100%11100%
File 1: <UserListAsync()100%11100%
File 1: UserDelete(...)100%11100%
File 1: <UserDeleteAsync()100%11100%
File 1: UserChangePassword(...)100%11100%
File 1: <UserChangePasswordAsync()100%11100%
File 1: UserGrantRole(...)100%11100%
File 1: <UserGrantRoleAsync()100%11100%
File 1: UserRevokeRole(...)100%11100%
File 1: <UserRevokeRoleAsync()100%11100%
File 1: RoleAdd(...)100%11100%
File 1: <RoleAddAsync()100%11100%
File 1: RoleGet(...)100%11100%
File 1: <RoleGetAsync()100%11100%
File 1: RoleList(...)100%11100%
File 1: <RoleListAsync()100%11100%
File 1: RoleDelete(...)100%11100%
File 1: <RoleDeleteAsync()100%11100%
File 1: RoleGrantPermission(...)100%11100%
File 1: <RoleGrantPermissionAsync()100%11100%
File 1: RoleRevokePermission(...)100%11100%
File 1: <RoleRevokePermissionAsync()100%11100%
File 1: AuthStatus(...)100%11100%
File 1: <AuthStatusAsync()100%11100%
File 2: MemberAdd(...)100%11100%
File 2: <MemberAddAsync()100%11100%
File 2: MemberRemove(...)100%11100%
File 2: <MemberRemoveAsync()100%11100%
File 2: MemberUpdate(...)100%11100%
File 2: <MemberUpdateAsync()100%11100%
File 2: MemberList(...)100%11100%
File 2: <MemberListAsync()100%11100%
File 2: MemberPromote(...)100%11100%
File 2: <MemberPromoteAsync()100%11100%
File 2: MemberPromote(...)100%11100%
File 2: MemberPromoteAsync()100%11100%
File 2: MemberAddAsLearner(...)100%22100%
File 2: MemberAddAsLearnerAsync()50%22100%
File 3: Campaign(...)50%22100%
File 3: Campaign(...)50%44100%
File 3: Campaign(...)75%44100%
File 3: <CampaignAsync()50%22100%
File 3: <CampaignAsync()50%44100%
File 3: CampaignAsync()50%44100%
File 3: Proclaim(...)50%22100%
File 3: Proclaim(...)50%44100%
File 3: <ProclaimAsync()50%22100%
File 3: <ProclaimAsync()50%44100%
File 3: Leader(...)50%22100%
File 3: Leader(...)50%22100%
File 3: <LeaderAsync()50%22100%
File 3: <LeaderAsync()50%22100%
File 3: ObserveAsync()100%44100%
File 3: ObserveAsync()100%44100%
File 3: Resign(...)50%22100%
File 3: Resign(...)50%22100%
File 3: <ResignAsync()50%22100%
File 3: <ResignAsync()50%22100%
File 3: Observe(...)100%22100%
File 3: Observe(...)100%22100%
File 4: GetConnection()100%11100%
File 4: GetWatchManager()100%11100%
File 4: CancelWatch(...)100%11100%
File 4: CancelWatch(...)100%22100%
File 4: get_Username()100%11100%
File 4: .ctor(...)100%11100%
File 4: .cctor()100%11100%
File 4: .ctor(...)75%8895.34%
File 4: .ctor(...)50%101091.3%
File 4: .ctor(...)83.33%66100%
File 4: .ctor(...)100%22100%
File 4: SetCredentials(...)50%8661.53%
File 4: ClearCredentials()100%11100%
File 4: EnsureAuthenticationSupported()50%2288.88%
File 4: RequestTokenAsync()100%22100%
File 4: Dispose(...)75%88100%
File 4: Dispose()100%11100%
File 5: Get(...)100%11100%
File 5: Get(...)100%11100%
File 5: <GetAsync()100%11100%
File 5: GetAsync()100%11100%
File 5: GetVal(...)100%22100%
File 5: GetValAsync()100%22100%
File 5: GetRange(...)100%11100%
File 5: GetRangeAsync()100%11100%
File 5: GetRangeVal(...)100%11100%
File 5: GetRangeValAsync()100%11100%
File 5: Put(...)100%11100%
File 5: Put(...)100%11100%
File 5: <PutAsync()100%11100%
File 5: PutAsync()100%11100%
File 5: Delete(...)100%11100%
File 5: Delete(...)100%11100%
File 5: <DeleteAsync()100%11100%
File 5: DeleteAsync()100%11100%
File 5: DeleteRange(...)100%11100%
File 5: DeleteRangeAsync()100%11100%
File 5: Transaction(...)100%11100%
File 5: <TransactionAsync()100%11100%
File 5: Compact(...)100%11100%
File 5: <CompactAsync()100%11100%
File 5: RangeStream()100%11100%
File 5: <RangeStream()100%44100%
File 5: RangeStreamAsync()100%11100%
File 6: LeaseGrant(...)100%11100%
File 6: <LeaseGrantAsync()100%11100%
File 6: LeaseRevoke(...)100%11100%
File 6: <LeaseRevokeAsync()100%11100%
File 6: LeaseKeepAlive(...)75%4496.15%
File 6: LeaseKeepAlive()100%11100%
File 6: <LeaseKeepAlive()83.33%66100%
File 6: LeaseKeepAlive()100%11100%
File 6: <LeaseKeepAlive()100%11100%
File 6: LeaseKeepAlive()100%11100%
File 6: <LeaseKeepAlive()100%11100%
File 6: LeaseKeepAlive()100%11100%
File 6: <LeaseKeepAlive()100%22100%
File 6: LeaseKeepAlive()100%11100%
File 6: <LeaseKeepAlive()100%22100%
File 6: LeaseTimeToLive(...)100%11100%
File 6: <LeaseTimeToLiveAsync()100%11100%
File 6: LeaseLeases(...)100%11100%
File 6: <LeaseLeasesAsync()100%11100%
File 6: LeaseLeases(...)100%11100%
File 6: LeaseLeasesAsync()100%11100%
File 7: Lock(...)100%11100%
File 7: Lock(...)100%11100%
File 7: Lock(...)100%11100%
File 7: LockAsync()100%11100%
File 7: LockAsync()100%11100%
File 7: LockAsync()100%11100%
File 7: <LockAsync()100%11100%
File 7: Unlock(...)100%11100%
File 7: Unlock(...)100%11100%
File 7: UnlockAsync()100%11100%
File 7: UnlockAsync()100%11100%
File 7: <UnlockAsync()100%11100%
File 8: Alarm(...)100%11100%
File 8: <AlarmAsync()100%11100%
File 8: Status(...)100%11100%
File 8: <StatusAsync()100%11100%
File 8: Defragment(...)100%11100%
File 8: <DefragmentAsync()100%11100%
File 8: Hash(...)100%11100%
File 8: <HashAsync()100%11100%
File 8: HashKV(...)100%11100%
File 8: <HashKVAsync()100%11100%
File 8: Snapshot()100%11100%
File 8: <Snapshot()100%22100%
File 8: Snapshot()100%11100%
File 8: <Snapshot()100%44100%
File 8: MoveLeader(...)100%11100%
File 8: <MoveLeaderAsync()100%11100%
File 8: Downgrade(...)100%11100%
File 8: <DowngradeAsync()100%11100%
File 9: RangeRespondToDictionary(...)100%22100%
File 9: GetRangeEnd(...)100%44100%
File 9: GetRangeEnd(...)100%11100%
File 9: GetStringByteForRangeRequests(...)100%22100%
File 9: CallEtcd(...)100%11100%
File 9: CallEtcdAsync(...)100%11100%
File 9: CallEtcdAsync(...)100%11100%
File 10: PairCallbacks(...)100%88100%
File 10: WatchAsync()100%22100%
File 10: WatchAsync(...)100%44100%
File 10: Watch(...)100%22100%
File 10: Watch(...)100%22100%
File 10: WatchAsync(...)100%11100%
File 10: WatchAsync(...)100%22100%
File 10: WatchAsync()100%22100%
File 10: WatchAsync()100%22100%
File 10: WatchAsync(...)100%11100%
File 10: WatchAsync(...)100%22100%
File 10: Watch(...)100%11100%
File 10: Watch(...)100%11100%
File 10: Watch(...)100%11100%
File 10: Watch(...)100%11100%
File 10: Watch(...)100%11100%
File 10: Watch(...)100%22100%
File 10: Watch(...)100%11100%
File 10: Watch(...)100%11100%
File 10: Watch(...)100%11100%
File 10: Watch(...)100%22100%
File 10: WatchAsync(...)100%11100%
File 10: WatchAsync(...)100%11100%
File 10: WatchAsync(...)100%11100%
File 10: WatchAsync(...)100%22100%
File 10: WatchAsync(...)100%11100%
File 10: WatchAsync(...)100%11100%
File 10: WatchAsync(...)100%11100%
File 10: WatchAsync(...)100%22100%
File 10: WatchRange(...)100%11100%
File 10: WatchRange(...)100%22100%
File 10: WatchRange(...)100%22100%
File 10: WatchRange(...)100%44100%
File 10: WatchRangeAsync(...)100%11100%
File 10: WatchRangeAsync(...)100%22100%
File 10: WatchRangeAsync()100%22100%
File 10: WatchRangeAsync()100%44100%

File(s)

/home/runner/work/dotnet-etcd/dotnet-etcd/dotnet-etcd/authClient.cs

#LineLine coverage
 1using System;
 2using System.Threading;
 3using System.Threading.Tasks;
 4using Etcdserverpb;
 5using Grpc.Core;
 6
 7namespace dotnet_etcd;
 8
 9public partial class EtcdClient
 10{
 11    /// <summary>
 12    ///     Authenticate processes an authenticate request.
 13    /// </summary>
 14    /// <param name="request">The request to send to the server.</param>
 15    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 16    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 17    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 18    /// <returns>The response received from the server.</returns>
 19    public AuthenticateResponse Authenticate(AuthenticateRequest request, Metadata headers = null,
 20        DateTime? deadline = null,
 621        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 622        .Authenticate(request, headers, deadline, cancellationToken));
 23
 24    /// <summary>
 25    ///     Authenticate processes an authenticate request.
 26    /// </summary>
 27    /// <param name="request">The request to send to the server.</param>
 28    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 29    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 30    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 31    /// <returns>The response received from the server.</returns>
 32    public async Task<AuthenticateResponse> AuthenticateAsync(AuthenticateRequest request,
 33        Metadata headers = null, DateTime? deadline = null,
 1034        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 1035        .AuthClient
 1036        .AuthenticateAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 37
 38    /// <summary>
 39    ///     AuthEnable enables authentication
 40    /// </summary>
 41    /// <param name="request">The request to send to the server.</param>
 42    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 43    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 44    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 45    /// <returns>The response received from the server.</returns>
 46    public AuthEnableResponse AuthEnable(AuthEnableRequest request, Metadata headers = null,
 47        DateTime? deadline = null,
 648        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 649        .AuthEnable(request, headers, deadline, cancellationToken));
 50
 51    /// <summary>
 52    ///     AuthEnableAsync enables authentication in async
 53    /// </summary>
 54    /// <param name="request">The request to send to the server.</param>
 55    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 56    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 57    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 58    /// <returns>The response received from the server.</returns>
 59    public async Task<AuthEnableResponse> AuthEnableAsync(AuthEnableRequest request,
 60        Metadata headers = null, DateTime? deadline = null,
 4061        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 4062        .AuthClient
 4063        .AuthEnableAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 64
 65    /// <summary>
 66    ///     AuthDisable disables authentication
 67    /// </summary>
 68    /// <param name="request">The request to send to the server.</param>
 69    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 70    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 71    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 72    /// <returns>The response received from the server.</returns>
 73    public AuthDisableResponse AuthDisable(AuthDisableRequest request, Metadata headers = null,
 74        DateTime? deadline = null,
 475        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 476        .AuthDisable(request, headers, deadline, cancellationToken));
 77
 78    /// <summary>
 79    ///     AuthDisableAsync disables authentication in async
 80    /// </summary>
 81    /// <param name="request">The request to send to the server.</param>
 82    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 83    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 84    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 85    /// <returns>The response received from the server.</returns>
 86    public async Task<AuthDisableResponse> AuthDisableAsync(AuthDisableRequest request,
 87        Metadata headers = null, DateTime? deadline = null,
 11488        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 11489        .AuthClient
 11490        .AuthDisableAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 91
 92    /// <summary>
 93    ///     UserAdd adds a new user
 94    /// </summary>
 95    /// <param name="request">The request to send to the server.</param>
 96    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 97    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 98    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 99    /// <returns>The response received from the server.</returns>
 100    public AuthUserAddResponse UserAdd(AuthUserAddRequest request, Metadata headers = null,
 101        DateTime? deadline = null,
 4102        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 4103        .UserAdd(request, headers, deadline, cancellationToken));
 104
 105    /// <summary>
 106    ///     UserAddAsync adds a new user in async
 107    /// </summary>
 108    /// <param name="request">The request to send to the server.</param>
 109    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 110    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 111    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 112    /// <returns>The response received from the server.</returns>
 113    public async Task<AuthUserAddResponse> UserAddAsync(AuthUserAddRequest request,
 114        Metadata headers = null, DateTime? deadline = null,
 98115        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 98116        .AuthClient
 98117        .UserAddAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 118
 119    /// <summary>
 120    ///     UserGet gets detailed user information
 121    /// </summary>
 122    /// <param name="request">The request to send to the server.</param>
 123    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 124    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 125    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 126    /// <returns>The response received from the server.</returns>
 127    public AuthUserGetResponse UserGet(AuthUserGetRequest request, Metadata headers = null,
 128        DateTime? deadline = null,
 2129        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 2130        .UserGet(request, headers, deadline, cancellationToken));
 131
 132    /// <summary>
 133    ///     UserGetAsync gets detailed user information in async
 134    /// </summary>
 135    /// <param name="request">The request to send to the server.</param>
 136    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 137    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 138    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 139    /// <returns>The response received from the server.</returns>
 140    public async Task<AuthUserGetResponse> UserGetAsync(AuthUserGetRequest request,
 141        Metadata headers = null, DateTime? deadline = null,
 2142        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 2143        .AuthClient
 2144        .UserGetAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 145
 146    /// <summary>
 147    ///     UserList gets a list of all users
 148    /// </summary>
 149    /// <param name="request">The request to send to the server.</param>
 150    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 151    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 152    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 153    /// <returns>The response received from the server.</returns>
 154    public AuthUserListResponse UserList(AuthUserListRequest request, Metadata headers = null,
 155        DateTime? deadline = null,
 4156        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 4157        .UserList(request, headers, deadline, cancellationToken));
 158
 159    /// <summary>
 160    ///     UserListAsync gets a list of all users in async
 161    /// </summary>
 162    /// <param name="request">The request to send to the server.</param>
 163    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 164    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 165    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 166    /// <returns>The response received from the server.</returns>
 167    public async Task<AuthUserListResponse> UserListAsync(AuthUserListRequest request,
 168        Metadata headers = null, DateTime? deadline = null,
 70169        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 70170        .AuthClient
 70171        .UserListAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 172
 173    /// <summary>
 174    ///     UserDelete deletes a specified user
 175    /// </summary>
 176    /// <param name="request">The request to send to the server.</param>
 177    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 178    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 179    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 180    /// <returns>The response received from the server.</returns>
 181    public AuthUserDeleteResponse UserDelete(AuthUserDeleteRequest request, Metadata headers = null,
 182        DateTime? deadline = null,
 4183        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 4184        .UserDelete(request, headers, deadline, cancellationToken));
 185
 186    /// <summary>
 187    ///     UserDeleteAsync deletes a specified user in async
 188    /// </summary>
 189    /// <param name="request">The request to send to the server.</param>
 190    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 191    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 192    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 193    /// <returns>The response received from the server.</returns>
 194    public async Task<AuthUserDeleteResponse> UserDeleteAsync(AuthUserDeleteRequest request,
 195        Metadata headers = null, DateTime? deadline = null,
 64196        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 64197        .AuthClient
 64198        .UserDeleteAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 199
 200    /// <summary>
 201    ///     UserChangePassword changes the password of a specified user
 202    /// </summary>
 203    /// <param name="request">The request to send to the server.</param>
 204    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 205    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 206    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 207    /// <returns>The response received from the server.</returns>
 208    public AuthUserChangePasswordResponse UserChangePassword(AuthUserChangePasswordRequest request,
 209        Metadata headers = null, DateTime? deadline = null,
 2210        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 2211        .UserChangePassword(request, headers, deadline, cancellationToken));
 212
 213    /// <summary>
 214    ///     UserChangePasswordAsync changes the password of a specified user in async
 215    /// </summary>
 216    /// <param name="request">The request to send to the server.</param>
 217    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 218    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 219    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 220    /// <returns>The response received from the server.</returns>
 221    public async Task<AuthUserChangePasswordResponse> UserChangePasswordAsync(AuthUserChangePasswordRequest request,
 222        Metadata headers = null, DateTime? deadline = null,
 6223        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 6224        .AuthClient
 6225        .UserChangePasswordAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 226
 227    /// <summary>
 228    ///     UserGrant grants a role to a specified user
 229    /// </summary>
 230    /// <param name="request">The request to send to the server.</param>
 231    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 232    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 233    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 234    /// <returns>The response received from the server.</returns>
 235    public AuthUserGrantRoleResponse UserGrantRole(AuthUserGrantRoleRequest request,
 236        Metadata headers = null, DateTime? deadline = null,
 2237        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 2238        .UserGrantRole(request, headers, deadline, cancellationToken));
 239
 240    /// <summary>
 241    ///     UserGrantRoleAsync grants a role to a specified user in async
 242    /// </summary>
 243    /// <param name="request">The request to send to the server.</param>
 244    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 245    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 246    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 247    /// <returns>The response received from the server.</returns>
 248    public async Task<AuthUserGrantRoleResponse> UserGrantRoleAsync(AuthUserGrantRoleRequest request,
 249        Metadata headers = null, DateTime? deadline = null,
 60250        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 60251        .AuthClient
 60252        .UserGrantRoleAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 253
 254    /// <summary>
 255    ///     UserRevokeRole revokes a role of specified user
 256    /// </summary>
 257    /// <param name="request">The request to send to the server.</param>
 258    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 259    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 260    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 261    /// <returns>The response received from the server.</returns>
 262    public AuthUserRevokeRoleResponse UserRevokeRole(AuthUserRevokeRoleRequest request,
 263        Metadata headers = null, DateTime? deadline = null,
 2264        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 2265        .UserRevokeRole(request, headers, deadline, cancellationToken));
 266
 267    /// <summary>
 268    ///     UserRevokeRoleAsync revokes a role of specified user in async
 269    /// </summary>
 270    /// <param name="request">The request to send to the server.</param>
 271    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 272    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 273    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 274    /// <returns>The response received from the server.</returns>
 275    public async Task<AuthUserRevokeRoleResponse> UserRevokeRoleAsync(AuthUserRevokeRoleRequest request,
 276        Metadata headers = null, DateTime? deadline = null,
 4277        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 4278        .AuthClient
 4279        .UserRevokeRoleAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 280
 281    /// <summary>
 282    ///     RoleAdd adds a new role
 283    /// </summary>
 284    /// <param name="request">The request to send to the server.</param>
 285    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 286    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 287    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 288    /// <returns>The response received from the server.</returns>
 289    public AuthRoleAddResponse RoleAdd(AuthRoleAddRequest request, Metadata headers = null,
 290        DateTime? deadline = null,
 4291        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 4292        .RoleAdd(request, headers, deadline, cancellationToken));
 293
 294    /// <summary>
 295    ///     RoleAddAsync adds a new role in async
 296    /// </summary>
 297    /// <param name="request">The request to send to the server.</param>
 298    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 299    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 300    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 301    /// <returns>The response received from the server.</returns>
 302    public async Task<AuthRoleAddResponse> RoleAddAsync(AuthRoleAddRequest request,
 303        Metadata headers = null, DateTime? deadline = null,
 6304        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 6305        .AuthClient
 6306        .RoleAddAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 307
 308    /// <summary>
 309    ///     RoleGet gets detailed role information
 310    /// </summary>
 311    /// <param name="request">The request to send to the server.</param>
 312    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 313    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 314    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 315    /// <returns>The response received from the server.</returns>
 316    public AuthRoleGetResponse RoleGet(AuthRoleGetRequest request, Metadata headers = null,
 317        DateTime? deadline = null,
 2318        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 2319        .RoleGet(request, headers, deadline, cancellationToken));
 320
 321    /// <summary>
 322    ///     RoleGetAsync gets detailed role information in async
 323    /// </summary>
 324    /// <param name="request">The request to send to the server.</param>
 325    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 326    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 327    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 328    /// <returns>The response received from the server.</returns>
 329    public async Task<AuthRoleGetResponse> RoleGetAsync(AuthRoleGetRequest request,
 330        Metadata headers = null, DateTime? deadline = null,
 2331        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 2332        .AuthClient
 2333        .RoleGetAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 334
 335    /// <summary>
 336    ///     RoleList gets lists of all roles
 337    /// </summary>
 338    /// <param name="request">The request to send to the server.</param>
 339    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 340    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 341    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 342    /// <returns>The response received from the server.</returns>
 343    public AuthRoleListResponse RoleList(AuthRoleListRequest request, Metadata headers = null,
 344        DateTime? deadline = null,
 2345        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 2346        .RoleList(request, headers, deadline, cancellationToken));
 347
 348    /// <summary>
 349    ///     RoleListAsync gets lists of all roles async
 350    /// </summary>
 351    /// <param name="request">The request to send to the server.</param>
 352    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 353    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 354    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 355    /// <returns>The response received from the server.</returns>
 356    public async Task<AuthRoleListResponse> RoleListAsync(AuthRoleListRequest request,
 357        Metadata headers = null, DateTime? deadline = null,
 68358        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 68359        .AuthClient
 68360        .RoleListAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 361
 362    /// <summary>
 363    ///     RoleDelete deletes a specified role
 364    /// </summary>
 365    /// <param name="request">The request to send to the server.</param>
 366    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 367    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 368    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 369    /// <returns>The response received from the server.</returns>
 370    public AuthRoleDeleteResponse RoleDelete(AuthRoleDeleteRequest request, Metadata headers = null,
 371        DateTime? deadline = null,
 2372        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 2373        .RoleDelete(request, headers, deadline, cancellationToken));
 374
 375    /// <summary>
 376    ///     RoleDeleteAsync deletes a specified role in async
 377    /// </summary>
 378    /// <param name="request">The request to send to the server.</param>
 379    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 380    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 381    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 382    /// <returns>The response received from the server.</returns>
 383    public async Task<AuthRoleDeleteResponse> RoleDeleteAsync(AuthRoleDeleteRequest request,
 384        Metadata headers = null, DateTime? deadline = null,
 6385        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 6386        .AuthClient
 6387        .RoleDeleteAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 388
 389    /// <summary>
 390    ///     RoleGrantPermission grants a permission of a specified key or range to a specified role
 391    /// </summary>
 392    /// <param name="request">The request to send to the server.</param>
 393    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 394    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 395    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 396    /// <returns>The response received from the server.</returns>
 397    public AuthRoleGrantPermissionResponse RoleGrantPermission(AuthRoleGrantPermissionRequest request,
 398        Metadata headers = null, DateTime? deadline = null,
 4399        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 4400        .RoleGrantPermission(request, headers, deadline, cancellationToken));
 401
 402    /// <summary>
 403    ///     RoleGrantPermissionAsync grants a permission of a specified key or range to a specified role in async
 404    /// </summary>
 405    /// <param name="request">The request to send to the server.</param>
 406    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 407    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 408    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 409    /// <returns>The response received from the server.</returns>
 410    public async Task<AuthRoleGrantPermissionResponse> RoleGrantPermissionAsync(
 411        AuthRoleGrantPermissionRequest request, Metadata headers = null, DateTime? deadline = null,
 6412        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 6413        .AuthClient
 6414        .RoleGrantPermissionAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 415
 416    /// <summary>
 417    ///     RoleRevokePermission revokes a key or range permission of a specified role
 418    /// </summary>
 419    /// <param name="request">The request to send to the server.</param>
 420    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 421    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 422    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 423    /// <returns>The response received from the server.</returns>
 424    public AuthRoleRevokePermissionResponse RoleRevokePermission(AuthRoleRevokePermissionRequest request,
 425        Metadata headers = null, DateTime? deadline = null,
 2426        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 2427        .RoleRevokePermission(request, headers, deadline, cancellationToken));
 428
 429    /// <summary>
 430    ///     RoleRevokePermissionAsync revokes a key or range permission of a specified role in async
 431    /// </summary>
 432    /// <param name="request">The request to send to the server.</param>
 433    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 434    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 435    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 436    /// <returns>The response received from the server.</returns>
 437    public async Task<AuthRoleRevokePermissionResponse> RoleRevokePermissionAsync(
 438        AuthRoleRevokePermissionRequest request, Metadata headers = null, DateTime? deadline = null,
 2439        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 2440        .AuthClient
 2441        .RoleRevokePermissionAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 442
 443    /// <summary>
 444    ///     AuthStatus reports whether authentication is enabled and the current auth revision. From etcd 3.7 this call 
 445    /// </summary>
 446    /// <param name="request">The request to send to the server.</param>
 447    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 448    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 449    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 450    /// <returns>The response received from the server.</returns>
 451    public AuthStatusResponse AuthStatus(AuthStatusRequest request, Metadata headers = null, DateTime? deadline = null,
 4452        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.AuthClient
 4453        .AuthStatus(request, headers, deadline, cancellationToken));
 454
 455    /// <summary>
 456    ///     AuthStatusAsync reports whether authentication is enabled and the current auth revision in async. From etcd 
 457    /// </summary>
 458    /// <param name="request">The request to send to the server.</param>
 459    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 460    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 461    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 462    /// <returns>The response received from the server.</returns>
 463    public async Task<AuthStatusResponse> AuthStatusAsync(AuthStatusRequest request, Metadata headers = null,
 464        DateTime? deadline = null,
 4465        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 4466        .AuthClient
 4467        .AuthStatusAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 468}

/home/runner/work/dotnet-etcd/dotnet-etcd/dotnet-etcd/clusterClient.cs

#LineLine coverage
 1using System;
 2using System.Threading;
 3using System.Threading.Tasks;
 4using Etcdserverpb;
 5using Grpc.Core;
 6
 7namespace dotnet_etcd;
 8
 9public partial class EtcdClient
 10{
 11    /// <summary>
 12    ///     MemberAdd adds a member into the cluster
 13    /// </summary>
 14    /// <param name="request">The request to send to the server.</param>
 15    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 16    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 17    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 18    /// <returns>The response received from the server.</returns>
 19    public MemberAddResponse MemberAdd(MemberAddRequest request, Metadata headers = null,
 20        DateTime? deadline = null,
 621        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.ClusterClient
 622        .MemberAdd(request, headers, deadline, cancellationToken));
 23
 24    /// <summary>
 25    ///     MemberAddAsync adds a member into the cluster in async
 26    /// </summary>
 27    /// <param name="request">The request to send to the server.</param>
 28    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 29    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 30    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 31    /// <returns>The response received from the server.</returns>
 32    public async Task<MemberAddResponse> MemberAddAsync(MemberAddRequest request, Metadata headers = null,
 33        DateTime? deadline = null,
 834        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 835        .ClusterClient
 836        .MemberAddAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 37
 38    /// <summary>
 39    ///     MemberRemove removes an existing member from the cluster
 40    /// </summary>
 41    /// <param name="request">The request to send to the server.</param>
 42    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 43    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 44    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 45    /// <returns>The response received from the server.</returns>
 46    public MemberRemoveResponse MemberRemove(MemberRemoveRequest request, Metadata headers = null,
 47        DateTime? deadline = null,
 448        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.ClusterClient
 449        .MemberRemove(request, headers, deadline, cancellationToken));
 50
 51    /// <summary>
 52    ///     MemberRemoveAsync removes an existing member from the cluster in async
 53    /// </summary>
 54    /// <param name="request">The request to send to the server.</param>
 55    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 56    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 57    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 58    /// <returns>The response received from the server.</returns>
 59    public async Task<MemberRemoveResponse> MemberRemoveAsync(MemberRemoveRequest request,
 60        Metadata headers = null, DateTime? deadline = null,
 461        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 462        .ClusterClient
 463        .MemberRemoveAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 64
 65    /// <summary>
 66    ///     MemberUpdate updates the member configuration
 67    /// </summary>
 68    /// <param name="request">The request to send to the server.</param>
 69    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 70    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 71    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 72    /// <returns>The response received from the server.</returns>
 73    public MemberUpdateResponse MemberUpdate(MemberUpdateRequest request, Metadata headers = null,
 74        DateTime? deadline = null,
 475        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.ClusterClient
 476        .MemberUpdate(request, headers, deadline, cancellationToken));
 77
 78    /// <summary>
 79    ///     MemberUpdateAsync updates the member configuration in async
 80    /// </summary>
 81    /// <param name="request">The request to send to the server.</param>
 82    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 83    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 84    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 85    /// <returns>The response received from the server.</returns>
 86    public async Task<MemberUpdateResponse> MemberUpdateAsync(MemberUpdateRequest request,
 87        Metadata headers = null, DateTime? deadline = null,
 488        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 489        .ClusterClient
 490        .MemberUpdateAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 91
 92    /// <summary>
 93    ///     MemberList lists all the members in the cluster
 94    /// </summary>
 95    /// <param name="request">The request to send to the server.</param>
 96    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 97    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 98    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 99    /// <returns>The response received from the server.</returns>
 100    public MemberListResponse MemberList(MemberListRequest request, Metadata headers = null,
 101        DateTime? deadline = null,
 4102        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.ClusterClient
 4103        .MemberList(request, headers, deadline, cancellationToken));
 104
 105    /// <summary>
 106    ///     MemberListAsync lists all the members in the cluster in async
 107    /// </summary>
 108    /// <param name="request">The request to send to the server.</param>
 109    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 110    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 111    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 112    /// <returns>The response received from the server.</returns>
 113    public async Task<MemberListResponse> MemberListAsync(MemberListRequest request,
 114        Metadata headers = null, DateTime? deadline = null,
 8115        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 8116        .ClusterClient
 8117        .MemberListAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 118
 119    /// <summary>
 120    ///     MemberPromote promotes a learner member to a voting member of the cluster.
 121    /// </summary>
 122    /// <param name="request">The request to send to the server.</param>
 123    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 124    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 125    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 126    /// <returns>The response received from the server.</returns>
 127    public MemberPromoteResponse MemberPromote(MemberPromoteRequest request, Metadata headers = null, DateTime? deadline
 4128        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.ClusterClient
 4129        .MemberPromote(request, headers, deadline, cancellationToken));
 130
 131    /// <summary>
 132    ///     MemberPromoteAsync promotes a learner member to a voting member of the cluster in async.
 133    /// </summary>
 134    /// <param name="request">The request to send to the server.</param>
 135    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 136    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 137    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 138    /// <returns>The response received from the server.</returns>
 139    public async Task<MemberPromoteResponse> MemberPromoteAsync(MemberPromoteRequest request, Metadata headers = null,
 140        DateTime? deadline = null,
 4141        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 4142        .ClusterClient
 4143        .MemberPromoteAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 144
 145    /// <summary>
 146    ///     MemberPromote promotes a learner member to a voting member of the cluster.
 147    /// </summary>
 148    /// <param name="memberId">The ID of the learner member to promote.</param>
 149    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 150    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 151    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 152    /// <returns>The response received from the server.</returns>
 153    public MemberPromoteResponse MemberPromote(ulong memberId, Metadata headers = null, DateTime? deadline = null,
 154        CancellationToken cancellationToken = default) =>
 1155        MemberPromote(new MemberPromoteRequest { ID = memberId }, headers, deadline, cancellationToken);
 156
 157    /// <summary>
 158    ///     MemberPromoteAsync promotes a learner member to a voting member of the cluster in async.
 159    /// </summary>
 160    /// <param name="memberId">The ID of the learner member to promote.</param>
 161    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 162    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 163    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 164    /// <returns>The response received from the server.</returns>
 165    public async Task<MemberPromoteResponse> MemberPromoteAsync(ulong memberId, Metadata headers = null,
 166        DateTime? deadline = null, CancellationToken cancellationToken = default) =>
 1167        await MemberPromoteAsync(new MemberPromoteRequest { ID = memberId }, headers, deadline, cancellationToken)
 1168            .ConfigureAwait(false);
 169
 170    /// <summary>
 171    ///     MemberAddAsLearner adds a non-voting learner member to the cluster. Promote it with
 172    ///     <see cref="MemberPromote(ulong, Metadata, DateTime?, CancellationToken)" /> once it has caught up.
 173    /// </summary>
 174    /// <param name="peerURLs">The peer URLs of the new learner member.</param>
 175    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 176    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 177    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 178    /// <returns>The response received from the server.</returns>
 179    public MemberAddResponse MemberAddAsLearner(string[] peerURLs, Metadata headers = null,
 180        DateTime? deadline = null, CancellationToken cancellationToken = default) =>
 2181        MemberAdd(new MemberAddRequest { PeerURLs = { peerURLs ?? throw new ArgumentNullException(nameof(peerURLs)) }, I
 2182            headers, deadline, cancellationToken);
 183
 184    /// <summary>
 185    ///     MemberAddAsLearnerAsync adds a non-voting learner member to the cluster in async. Promote it with
 186    ///     <see cref="MemberPromoteAsync(ulong, Metadata, DateTime?, CancellationToken)" /> once it has caught up.
 187    /// </summary>
 188    /// <param name="peerURLs">The peer URLs of the new learner member.</param>
 189    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 190    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 191    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 192    /// <returns>The response received from the server.</returns>
 193    public async Task<MemberAddResponse> MemberAddAsLearnerAsync(string[] peerURLs, Metadata headers = null,
 194        DateTime? deadline = null, CancellationToken cancellationToken = default) =>
 1195        await MemberAddAsync(
 1196                new MemberAddRequest { PeerURLs = { peerURLs ?? throw new ArgumentNullException(nameof(peerURLs)) }, IsL
 1197                headers, deadline, cancellationToken)
 1198            .ConfigureAwait(false);
 199}

/home/runner/work/dotnet-etcd/dotnet-etcd/dotnet-etcd/electionClient.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Runtime.CompilerServices;
 4using System.Threading;
 5using System.Threading.Tasks;
 6using Google.Protobuf;
 7using Grpc.Core;
 8using V3Electionpb;
 9
 10namespace dotnet_etcd;
 11
 12public partial class EtcdClient
 13{
 14    /// <summary>
 15    ///     Campaign waits to acquire leadership in an election, returning a LeaderKey
 16    ///     representing the leadership if successful. The LeaderKey can then be used
 17    ///     to issue new values on the election, transactionally guard API requests on
 18    ///     leadership still being held, and resign from the election.
 19    /// </summary>
 20    /// <param name="request">The request to send to the server.</param>
 21    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 22    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 23    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 24    /// <returns>The response received from the server.</returns>
 25    public CampaignResponse Campaign(
 26        CampaignRequest request,
 27        Metadata headers = null,
 28        DateTime? deadline = null,
 29        CancellationToken cancellationToken = default)
 1630        => CallEtcd(connection => connection.ElectionClient.Campaign(
 1631            request ?? throw new ArgumentNullException(nameof(request)),
 1632            headers,
 1633            deadline,
 1634            cancellationToken));
 35
 36    /// <summary>
 37    ///     Campaign waits to acquire leadership in an election, returning a LeaderKey
 38    ///     representing the leadership if successful. The LeaderKey can then be used
 39    ///     to issue new values on the election, transactionally guard API requests on
 40    ///     leadership still being held, and resign from the election.
 41    /// </summary>
 42    /// <param name="name">The name is the election�s identifier for the campaign.</param>
 43    /// <param name="value">The value is the initial proclaimed value set when the campaigner wins the election.</param>
 44    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 45    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 46    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 47    /// <returns>The response received from the server.</returns>
 48    /// <remarks>
 49    ///     This overload sends no lease. etcd's election server responds to an unset lease by
 50    ///     creating a session of its own with the default TTL of 60 seconds and immediately
 51    ///     orphaning it, so nothing keeps that lease alive: leadership is released roughly 60
 52    ///     seconds after it is won, while the caller is still running and with no signal that it
 53    ///     is no longer the leader. Use the overload that takes an explicit lease.
 54    /// </remarks>
 55    [Obsolete(
 56        "Campaign without an explicit lease gives up leadership after ~60 seconds with no signal " +
 57        "to the caller, because etcd creates and orphans a session of its own. Grant a lease, keep " +
 58        "it alive with LeaseKeepAlive, and pass its id to Campaign(name, leaseId, value, ...).")]
 59    public CampaignResponse Campaign(
 60        string name,
 61        string value = null,
 62        Metadata headers = null,
 63        DateTime? deadline = null,
 64        CancellationToken cancellationToken = default)
 265        => CallEtcd(connection => connection.ElectionClient.Campaign(
 266            new CampaignRequest
 267            {
 268                Name = ByteString.CopyFromUtf8(name ?? throw new ArgumentNullException(nameof(name))),
 269                Value = value == null ? null : ByteString.CopyFromUtf8(value)
 270            },
 271            headers,
 272            deadline,
 273            cancellationToken));
 74
 75    /// <summary>
 76    ///     Campaign waits to acquire leadership in an election, returning a LeaderKey
 77    ///     representing the leadership if successful. The LeaderKey can then be used
 78    ///     to issue new values on the election, transactionally guard API requests on
 79    ///     leadership still being held, and resign from the election.
 80    /// </summary>
 81    /// <param name="name">The name is the election's identifier for the campaign.</param>
 82    /// <param name="leaseId">
 83    ///     The id of the lease that leadership is attached to. Leadership lasts exactly as long as
 84    ///     this lease does, so the caller is responsible for keeping it alive (see
 85    ///     <see cref="LeaseKeepAlive(CancellationTokenSource, long, int, int?, Metadata, DateTime?)" />);
 86    ///     when the lease expires or is revoked, leadership passes to the next campaigner.
 87    /// </param>
 88    /// <param name="value">The value is the initial proclaimed value set when the campaigner wins the election.</param>
 89    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 90    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 91    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 92    /// <returns>The response received from the server.</returns>
 93    public CampaignResponse Campaign(
 94        string name,
 95        long leaseId,
 96        string value = null,
 97        Metadata headers = null,
 98        DateTime? deadline = null,
 99        CancellationToken cancellationToken = default)
 2100        => Campaign(
 2101            new CampaignRequest
 2102            {
 2103                Name = ByteString.CopyFromUtf8(name ?? throw new ArgumentNullException(nameof(name))),
 2104                Value = value == null ? null : ByteString.CopyFromUtf8(value),
 2105                Lease = leaseId
 2106            },
 2107            headers,
 2108            deadline,
 2109            cancellationToken);
 110
 111    /// <summary>
 112    ///     CampaignAsync waits to acquire leadership in an election, returning a LeaderKey
 113    ///     representing the leadership if successful. The LeaderKey can then be used
 114    ///     to issue new values on the election, transactionally guard API requests on
 115    ///     leadership still being held, and resign from the election.
 116    /// </summary>
 117    /// <param name="request">The request to send to the server.</param>
 118    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 119    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 120    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 121    /// <returns>The response received from the server.</returns>
 122    public async Task<CampaignResponse> CampaignAsync(
 123        CampaignRequest request,
 124        Metadata headers = null,
 125        DateTime? deadline = null,
 126        CancellationToken cancellationToken = default)
 22127        => await CallEtcdAsync(async connection => await connection.ElectionClient.CampaignAsync(
 22128            request ?? throw new ArgumentNullException(nameof(request)),
 22129            headers,
 22130            deadline,
 22131            cancellationToken)).ConfigureAwait(false);
 132
 133    /// <summary>
 134    ///     Campaign waits to acquire leadership in an election, returning a LeaderKey
 135    ///     representing the leadership if successful. The LeaderKey can then be used
 136    ///     to issue new values on the election, transactionally guard API requests on
 137    ///     leadership still being held, and resign from the election.
 138    /// </summary>
 139    /// <param name="name">The name is the election�s identifier for the campaign.</param>
 140    /// <param name="value">The value is the initial proclaimed value set when the campaigner wins the election.</param>
 141    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 142    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 143    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 144    /// <returns>The response received from the server.</returns>
 145    /// <remarks>
 146    ///     This overload sends no lease. etcd's election server responds to an unset lease by
 147    ///     creating a session of its own with the default TTL of 60 seconds and immediately
 148    ///     orphaning it, so nothing keeps that lease alive: leadership is released roughly 60
 149    ///     seconds after it is won, while the caller is still running and with no signal that it
 150    ///     is no longer the leader. Use the overload that takes an explicit lease.
 151    /// </remarks>
 152    [Obsolete(
 153        "CampaignAsync without an explicit lease gives up leadership after ~60 seconds with no " +
 154        "signal to the caller, because etcd creates and orphans a session of its own. Grant a lease, " +
 155        "keep it alive with LeaseKeepAlive, and pass its id to CampaignAsync(name, leaseId, value, ...).")]
 156    public async Task<CampaignResponse> CampaignAsync(
 157        string name,
 158        string value,
 159        Metadata headers = null,
 160        DateTime? deadline = null,
 161        CancellationToken cancellationToken = default)
 4162        => await CallEtcdAsync(async connection => await connection.ElectionClient.CampaignAsync(
 4163            new CampaignRequest
 4164            {
 4165                Name = ByteString.CopyFromUtf8(name ?? throw new ArgumentNullException(nameof(name))),
 4166                Value = value == null ? null : ByteString.CopyFromUtf8(value)
 4167            },
 4168            headers,
 4169            deadline,
 4170            cancellationToken)).ConfigureAwait(false);
 171
 172    /// <summary>
 173    ///     CampaignAsync waits to acquire leadership in an election, returning a LeaderKey
 174    ///     representing the leadership if successful. The LeaderKey can then be used
 175    ///     to issue new values on the election, transactionally guard API requests on
 176    ///     leadership still being held, and resign from the election.
 177    /// </summary>
 178    /// <param name="name">The name is the election's identifier for the campaign.</param>
 179    /// <param name="leaseId">
 180    ///     The id of the lease that leadership is attached to. Leadership lasts exactly as long as
 181    ///     this lease does, so the caller is responsible for keeping it alive (see
 182    ///     <see cref="LeaseKeepAlive(CancellationTokenSource, long, int, int?, Metadata, DateTime?)" />);
 183    ///     when the lease expires or is revoked, leadership passes to the next campaigner.
 184    /// </param>
 185    /// <param name="value">The value is the initial proclaimed value set when the campaigner wins the election.</param>
 186    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 187    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 188    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 189    /// <returns>The response received from the server.</returns>
 190    public async Task<CampaignResponse> CampaignAsync(
 191        string name,
 192        long leaseId,
 193        string value = null,
 194        Metadata headers = null,
 195        DateTime? deadline = null,
 196        CancellationToken cancellationToken = default)
 4197        => await CampaignAsync(
 4198            new CampaignRequest
 4199            {
 4200                Name = ByteString.CopyFromUtf8(name ?? throw new ArgumentNullException(nameof(name))),
 4201                Value = value == null ? null : ByteString.CopyFromUtf8(value),
 4202                Lease = leaseId
 4203            },
 4204            headers,
 4205            deadline,
 4206            cancellationToken).ConfigureAwait(false);
 207
 208    /// <summary>
 209    ///     Proclaim updates the leader's posted value with a new value.
 210    /// </summary>
 211    /// <param name="request">The request to send to the server.</param>
 212    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 213    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 214    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 215    /// <returns>The response received from the server.</returns>
 216    public ProclaimResponse Proclaim(
 217        ProclaimRequest request,
 218        Metadata headers = null,
 219        DateTime? deadline = null,
 220        CancellationToken cancellationToken = default)
 6221        => CallEtcd(connection => connection.ElectionClient.Proclaim(
 6222            request ?? throw new ArgumentNullException(nameof(request)),
 6223            headers,
 6224            deadline,
 6225            cancellationToken));
 226
 227    /// <summary>
 228    ///     Proclaim updates the leader's posted value with a new value.
 229    /// </summary>
 230    /// <param name="leader">The leader is the leadership hold on the election.</param>
 231    /// <param name="value">The value is an update meant to overwrite the leader�s current value.</param>
 232    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 233    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 234    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 235    /// <returns>The response received from the server.</returns>
 236    public ProclaimResponse Proclaim(
 237        LeaderKey leader,
 238        string value,
 239        Metadata headers = null,
 240        DateTime? deadline = null,
 241        CancellationToken cancellationToken = default)
 2242        => CallEtcd(connection => connection.ElectionClient.Proclaim(
 2243            new ProclaimRequest
 2244            {
 2245                Leader = leader ?? throw new ArgumentNullException(nameof(leader)),
 2246                Value = ByteString.CopyFromUtf8(value ?? throw new ArgumentNullException(nameof(value)))
 2247            },
 2248            headers,
 2249            deadline,
 2250            cancellationToken));
 251
 252    /// <summary>
 253    ///     Proclaim updates the leader's posted value with a new value.
 254    /// </summary>
 255    /// <param name="request">The request to send to the server.</param>
 256    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 257    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 258    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 259    /// <returns>The response received from the server.</returns>
 260    public async Task<ProclaimResponse> ProclaimAsync(
 261        ProclaimRequest request,
 262        Metadata headers = null,
 263        DateTime? deadline = null,
 264        CancellationToken cancellationToken = default)
 6265        => await CallEtcdAsync(async connection => await connection.ElectionClient.ProclaimAsync(
 6266            request ?? throw new ArgumentNullException(nameof(request)),
 6267            headers,
 6268            deadline,
 6269            cancellationToken)).ConfigureAwait(false);
 270
 271    /// <summary>
 272    ///     Proclaim updates the leader's posted value with a new value.
 273    /// </summary>
 274    /// <param name="leader">The leader is the leadership hold on the election.</param>
 275    /// <param name="value">The value is an update meant to overwrite the leader�s current value.</param>
 276    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 277    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 278    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 279    /// <returns>The response received from the server.</returns>
 280    public async Task<ProclaimResponse> ProclaimAsync(
 281        LeaderKey leader,
 282        string value,
 283        Metadata headers = null,
 284        DateTime? deadline = null,
 285        CancellationToken cancellationToken = default)
 2286        => await CallEtcdAsync(async connection => await connection.ElectionClient.ProclaimAsync(
 2287            new ProclaimRequest
 2288            {
 2289                Leader = leader ?? throw new ArgumentNullException(nameof(leader)),
 2290                Value = ByteString.CopyFromUtf8(value ?? throw new ArgumentNullException(nameof(value)))
 2291            },
 2292            headers,
 2293            deadline,
 2294            cancellationToken)).ConfigureAwait(false);
 295
 296    /// <summary>
 297    ///     Leader returns the current election proclamation, if any.
 298    /// </summary>
 299    /// <param name="request">The request to send to the server.</param>
 300    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 301    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 302    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 303    /// <returns>The response received from the server.</returns>
 304    public LeaderResponse Leader(
 305        LeaderRequest request,
 306        Metadata headers = null,
 307        DateTime? deadline = null,
 308        CancellationToken cancellationToken = default)
 6309        => CallEtcd(connection => connection.ElectionClient.Leader(
 6310            request ?? throw new ArgumentNullException(nameof(request)),
 6311            headers,
 6312            deadline,
 6313            cancellationToken));
 314
 315    /// <summary>
 316    ///     Leader returns the current election proclamation, if any.
 317    /// </summary>
 318    /// <param name="name">The name is the election identifier for the leadership information.</param>
 319    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 320    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 321    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 322    /// <returns>The response received from the server.</returns>
 323    public LeaderResponse Leader(
 324        string name,
 325        Metadata headers = null,
 326        DateTime? deadline = null,
 327        CancellationToken cancellationToken = default)
 6328        => CallEtcd(connection => connection.ElectionClient.Leader(
 6329            new LeaderRequest { Name = ByteString.CopyFromUtf8(name ?? throw new ArgumentNullException(nameof(name))) },
 6330            headers,
 6331            deadline,
 6332            cancellationToken));
 333
 334    /// <summary>
 335    ///     Leader returns the current election proclamation, if any.
 336    /// </summary>
 337    /// <param name="request">The request to send to the server.</param>
 338    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 339    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 340    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 341    /// <returns>The response received from the server.</returns>
 342    public async Task<LeaderResponse> LeaderAsync(
 343        LeaderRequest request,
 344        Metadata headers = null,
 345        DateTime? deadline = null,
 346        CancellationToken cancellationToken = default)
 6347        => await CallEtcdAsync(async connection => await connection.ElectionClient.LeaderAsync(
 6348            request ?? throw new ArgumentNullException(nameof(request)),
 6349            headers,
 6350            deadline,
 6351            cancellationToken)).ConfigureAwait(false);
 352
 353    /// <summary>
 354    ///     Leader returns the current election proclamation, if any.
 355    /// </summary>
 356    /// <param name="name">The name is the election identifier for the leadership information.</param>
 357    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 358    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 359    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 360    /// <returns>The response received from the server.</returns>
 361    public async Task<LeaderResponse> LeaderAsync(
 362        string name,
 363        Metadata headers = null,
 364        DateTime? deadline = null,
 365        CancellationToken cancellationToken = default)
 10366        => await CallEtcdAsync(async connection => await connection.ElectionClient.LeaderAsync(
 10367            new LeaderRequest { Name = ByteString.CopyFromUtf8(name ?? throw new ArgumentNullException(nameof(name))) },
 10368            headers,
 10369            deadline,
 10370            cancellationToken)).ConfigureAwait(false);
 371
 372    /// <summary>
 373    ///     Observe streams election proclamations in-order as made by the election's
 374    ///     elected leaders.
 375    /// </summary>
 376    /// <param name="request">The request to send to the server.</param>
 377    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 378    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 379    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 380    /// <returns>The response received from the server.</returns>
 381    public async IAsyncEnumerable<LeaderResponse> ObserveAsync(
 382        LeaderRequest request,
 383        Metadata headers = null,
 384        DateTime? deadline = null,
 385        [EnumeratorCancellation] CancellationToken cancellationToken = default)
 2386    {
 2387        using (AsyncServerStreamingCall<LeaderResponse> leaderResponse = _connection.ElectionClient.Observe(
 2388                   request ?? throw new ArgumentNullException(nameof(request)),
 2389                   headers,
 2390                   deadline,
 2391                   cancellationToken))
 1392        {
 4393            while (await leaderResponse.ResponseStream.MoveNext(cancellationToken).ConfigureAwait(false))
 3394            {
 3395                yield return leaderResponse.ResponseStream.Current;
 3396            }
 1397        }
 1398    }
 399
 400    /// <summary>
 401    ///     Observe streams election proclamations in-order as made by the election's
 402    ///     elected leaders.
 403    /// </summary>
 404    /// <param name="name">The name is the election identifier for the leadership information.</param>
 405    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 406    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 407    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 408    /// <returns>The response received from the server.</returns>
 409    public async IAsyncEnumerable<LeaderResponse> ObserveAsync(
 410        string name,
 411        Metadata headers = null,
 412        DateTime? deadline = null,
 413        [EnumeratorCancellation] CancellationToken cancellationToken = default)
 2414    {
 2415        using (AsyncServerStreamingCall<LeaderResponse> leaderResponse = _connection.ElectionClient.Observe(
 2416                   new LeaderRequest
 2417                   {
 2418                       Name = ByteString.CopyFromUtf8(name ?? throw new ArgumentNullException(nameof(name)))
 2419                   },
 2420                   headers,
 2421                   deadline,
 2422                   cancellationToken))
 1423        {
 2424            while (await leaderResponse.ResponseStream.MoveNext(cancellationToken).ConfigureAwait(false))
 1425            {
 1426                yield return leaderResponse.ResponseStream.Current;
 1427            }
 1428        }
 1429    }
 430
 431    /// <summary>
 432    ///     Resign releases election leadership so other campaigners may acquire
 433    ///     leadership on the election.
 434    /// </summary>
 435    /// <param name="request">The request to send to the server.</param>
 436    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 437    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 438    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 439    /// <returns>The response received from the server.</returns>
 440    public ResignResponse Resign(
 441        ResignRequest request,
 442        Metadata headers = null,
 443        DateTime? deadline = null,
 444        CancellationToken cancellationToken = default)
 14445        => CallEtcd(connection => connection.ElectionClient.Resign(
 14446            request ?? throw new ArgumentNullException(nameof(request)),
 14447            headers,
 14448            deadline,
 14449            cancellationToken));
 450
 451    /// <summary>
 452    ///     Resign releases election leadership so other campaigners may acquire
 453    ///     leadership on the election.
 454    /// </summary>
 455    /// <param name="leader">The leader is the leadership to relinquish by resignation.</param>
 456    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 457    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 458    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 459    /// <returns>The response received from the server.</returns>
 460    public ResignResponse Resign(
 461        LeaderKey leader,
 462        Metadata headers = null,
 463        DateTime? deadline = null,
 464        CancellationToken cancellationToken = default)
 2465        => CallEtcd(connection => connection.ElectionClient.Resign(
 2466            new ResignRequest { Leader = leader ?? throw new ArgumentNullException(nameof(leader)) },
 2467            headers,
 2468            deadline,
 2469            cancellationToken));
 470
 471    /// <summary>
 472    ///     Resign releases election leadership so other campaigners may acquire
 473    ///     leadership on the election.
 474    /// </summary>
 475    /// <param name="request">The request to send to the server.</param>
 476    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 477    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 478    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 479    /// <returns>The response received from the server.</returns>
 480    public async Task<ResignResponse> ResignAsync(
 481        ResignRequest request,
 482        Metadata headers = null,
 483        DateTime? deadline = null,
 484        CancellationToken cancellationToken = default)
 20485        => await CallEtcdAsync(async connection => await connection.ElectionClient.ResignAsync(
 20486            request ?? throw new ArgumentNullException(nameof(request)),
 20487            headers,
 20488            deadline,
 20489            cancellationToken)).ConfigureAwait(false);
 490
 491    /// <summary>
 492    ///     Resign releases election leadership so other campaigners may acquire
 493    ///     leadership on the election.
 494    /// </summary>
 495    /// <param name="leader">The leader is the leadership to relinquish by resignation.</param>
 496    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 497    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 498    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 499    /// <returns>The response received from the server.</returns>
 500    public async Task<ResignResponse> ResignAsync(
 501        LeaderKey leader,
 502        Metadata headers = null,
 503        DateTime? deadline = null,
 504        CancellationToken cancellationToken = default)
 2505        => await CallEtcdAsync(async connection => await connection.ElectionClient.ResignAsync(
 2506            new ResignRequest { Leader = leader ?? throw new ArgumentNullException(nameof(leader)) },
 2507            headers,
 2508            deadline,
 2509            cancellationToken)).ConfigureAwait(false);
 510
 511    /// <summary>
 512    ///     Observe streams election proclamations in-order as made by the election's
 513    ///     elected leaders.
 514    /// </summary>
 515    /// <param name="request">The request to send to the server.</param>
 516    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 517    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 518    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 519    /// <returns>The response received from the server.</returns>
 520    public AsyncServerStreamingCall<LeaderResponse> Observe(
 521        LeaderRequest request,
 522        Metadata headers = null,
 523        DateTime? deadline = null,
 524        CancellationToken cancellationToken = default)
 4525        => CallEtcd(connection => connection.ElectionClient.Observe(
 4526            request ?? throw new ArgumentNullException(nameof(request)),
 4527            headers,
 4528            deadline,
 4529            cancellationToken));
 530
 531    /// <summary>
 532    ///     Observe streams election proclamations in-order as made by the election's
 533    ///     elected leaders.
 534    /// </summary>
 535    /// <param name="name">The name is the election identifier for the leadership information.</param>
 536    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 537    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 538    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 539    /// <returns>The response received from the server.</returns>
 540    public AsyncServerStreamingCall<LeaderResponse> Observe(
 541        string name,
 542        Metadata headers = null,
 543        DateTime? deadline = null,
 544        CancellationToken cancellationToken = default)
 4545        => CallEtcd(connection => connection.ElectionClient.Observe(
 4546            new LeaderRequest { Name = ByteString.CopyFromUtf8(name ?? throw new ArgumentNullException(nameof(name))) },
 4547            headers,
 4548            deadline,
 4549            cancellationToken));
 550}

/home/runner/work/dotnet-etcd/dotnet-etcd/dotnet-etcd/etcdClient.cs

#LineLine coverage
 1using System;
 2using System.Net.Security;
 3using System.Threading;
 4using System.Threading.Tasks;
 5using dotnet_etcd.interfaces;
 6using dotnet_etcd.multiplexer;
 7using Etcdserverpb;
 8using Grpc.Core;
 9using Grpc.Core.Interceptors;
 10using Grpc.Net.Client;
 11using Grpc.Net.Client.Configuration;
 12
 13namespace dotnet_etcd;
 14
 15/// <summary>
 16///     Etcd client is the entrypoint for this library.
 17///     It contains all the functions required to perform operations on etcd.
 18/// </summary>
 19public partial class EtcdClient : IDisposable, IEtcdClient
 20{
 21    /// <summary>
 22    ///     Gets the connection object
 23    /// </summary>
 24    /// <returns>The connection object</returns>
 125    public IConnection GetConnection() => _connection;
 26
 27    /// <summary>
 28    ///     Gets the watch manager
 29    /// </summary>
 30    /// <returns>The watch manager</returns>
 731    public IWatchManager GetWatchManager() => _watchManager;
 32
 33    /// <summary>
 34    ///     Cancels a watch request
 35    /// </summary>
 36    /// <param name="watchId">The ID of the watch to cancel</param>
 137    public void CancelWatch(long watchId) => _watchManager.CancelWatch(watchId);
 38
 39    /// <summary>
 40    ///     Cancels multiple watch requests
 41    /// </summary>
 42    /// <param name="watchIds">The IDs of the watches to cancel</param>
 43    public void CancelWatch(long[] watchIds)
 244    {
 1245        foreach (long watchId in watchIds)
 346        {
 347            _watchManager.CancelWatch(watchId);
 348        }
 249    }
 50
 51    #region Variables
 52
 53    private const string InsecurePrefix = "http://";
 54    private const string SecurePrefix = "https://";
 55
 56    private const string StaticHostsPrefix = "static://";
 57    private const string DnsPrefix = "dns://";
 58    private const string AlternateDnsPrefix = "discovery-srv://";
 59
 60    private const string DefaultServerName = "my-etcd-server";
 61
 62    internal readonly IConnection _connection;
 63    private readonly GrpcChannel _channel;
 64    private readonly IWatchManager _watchManager;
 65    private readonly AsyncStreamCallFactory<WatchRequest, WatchResponse> _watchCallFactory;
 66
 17267    private sealed record EtcdCredentials(string Username, string Password);
 68
 69    private volatile EtcdCredentials _credentials;
 70    private AuthenticationHttpHandler _authHttpHandler;
 71
 72    // ETCD Tokens are valid for 5 min per default, so we cache them for the 5 min - 1 min safety margin.
 41473    private TimeSpan _tokenCacheDuration = TimeSpan.FromMinutes(4);
 74
 75    // https://learn.microsoft.com/en-us/aspnet/core/grpc/retries?view=aspnetcore-6.0#configure-a-grpc-retry-policy
 176    private static readonly MethodConfig _defaultGrpcMethodConfig = new()
 177    {
 178        Names = { MethodName.Default },
 179        RetryPolicy = new RetryPolicy
 180        {
 181            MaxAttempts = 5,
 182            InitialBackoff = TimeSpan.FromSeconds(1),
 183            MaxBackoff = TimeSpan.FromSeconds(5),
 184            BackoffMultiplier = 1.5,
 185            RetryableStatusCodes = { StatusCode.Unavailable },
 186        },
 187    };
 88
 89    // https://github.com/grpc/proposal/blob/master/A6-client-retries.md#throttling-retry-attempts-and-hedged-rpcs
 190    private static readonly RetryThrottlingPolicy _defaultRetryThrottlingPolicy = new()
 191    {
 192        MaxTokens = 10,
 193        TokenRatio = 0.1,
 194    };
 95
 96    #endregion
 97
 98    #region Initializers
 99
 100    /// <summary>
 101    ///     Initializes a new instance of the <see cref="EtcdClient" /> class with a CallInvoker.
 102    ///     Automatic authentication is not configured for this overload â€” the caller is responsible
 103    ///     for attaching any auth credentials to the supplied CallInvoker.
 104    /// </summary>
 105    /// <param name="callInvoker">The call invoker to use for gRPC calls</param>
 106    /// <exception cref="ArgumentNullException">Thrown if callInvoker is null</exception>
 237107    public EtcdClient(CallInvoker callInvoker)
 237108    {
 237109        ArgumentNullException.ThrowIfNull(callInvoker);
 110
 236111        _connection = new Connection(callInvoker);
 112
 113        // Create the watch call factory
 236114        _watchCallFactory = new AsyncStreamCallFactory<WatchRequest, WatchResponse>(
 236115            (headers, deadline, cancellationToken) =>
 0116                _connection.WatchClient.Watch(headers, deadline, cancellationToken)
 236117        );
 118
 119        // Initialize the watch manager
 236120        _watchManager = new WatchManager(
 236121            (headers, deadline, cancellationToken) =>
 0122                _watchCallFactory.CreateDuplexStreamingCall(headers, deadline, cancellationToken)
 236123        );
 236124    }
 125
 126    /// <summary>
 127    ///     Initializes a new instance of the <see cref="EtcdClient" /> class with a connection string.
 128    /// </summary>
 129    /// <param name="connectionString">The connection string for etcd</param>
 130    /// <param name="port">The port to connect to</param>
 131    /// <param name="serverName">The server name</param>
 132    /// <param name="configureChannelOptions">Function to configure channel options</param>
 133    /// <param name="interceptors">Interceptors to apply to calls</param>
 134    /// <exception cref="ArgumentNullException">Thrown if connectionString is null or empty</exception>
 123135    public EtcdClient(
 123136        string connectionString,
 123137        int port = 2379,
 123138        string serverName = DefaultServerName,
 123139        Action<GrpcChannelOptions> configureChannelOptions = null,
 123140        Interceptor[] interceptors = null
 123141    )
 123142    {
 143        // Param check
 123144        if (string.IsNullOrWhiteSpace(connectionString))
 3145        {
 3146            throw new ArgumentNullException(nameof(connectionString));
 147        }
 148
 149        // Param sanitization
 120150        interceptors ??= Array.Empty<Interceptor>();
 151
 120152        var channelFactory = new GrpcChannelFactory();
 120153        _channel = channelFactory.CreateChannel(
 120154            connectionString,
 120155            port,
 120156            serverName,
 120157            ChannelCredentials.Insecure, // Default to insecure for backward compatibility
 120158            options =>
 120159            {
 120160                configureChannelOptions?.Invoke(options);
 120161                _authHttpHandler = new AuthenticationHttpHandler(
 120162                    RequestTokenAsync,
 120163                    options.HttpHandler!
 120164                );
 120165                options.HttpHandler = _authHttpHandler;
 120166            },
 120167            configureSslOptions: null // No custom SSL by default
 120168        );
 169
 120170        CallInvoker callInvoker =
 120171            interceptors.Length > 0
 120172                ? _channel.Intercept(interceptors)
 120173                : _channel.CreateCallInvoker();
 174
 175        // Setup Connection
 120176        _connection = new Connection(callInvoker);
 177
 178        // Create the watch call factory
 120179        _watchCallFactory = new AsyncStreamCallFactory<WatchRequest, WatchResponse>(
 120180            (headers, deadline, cancellationToken) =>
 9181                _connection.WatchClient.Watch(headers, deadline, cancellationToken)
 120182        );
 183
 184        // Initialize the watch manager
 120185        _watchManager = new WatchManager(
 120186            (headers, deadline, cancellationToken) =>
 9187                _watchCallFactory.CreateDuplexStreamingCall(headers, deadline, cancellationToken)
 120188        );
 120189    }
 190
 191    /// <summary>
 192    ///     Initializes a new instance of the <see cref="EtcdClient" /> class with a connection string and SSL options c
 193    ///     Use this constructor to configure custom SSL certificates for self-signed certificates.
 194    /// </summary>
 195    /// <param name="connectionString">The connection string for etcd</param>
 196    /// <param name="configureSslOptions">Action to configure SSL options for custom SSL certificates</param>
 197    /// <param name="port">The port to connect to</param>
 198    /// <param name="serverName">The server name</param>
 199    /// <param name="configureChannelOptions">Function to configure channel options</param>
 200    /// <param name="interceptors">Interceptors to apply to calls</param>
 201    /// <exception cref="ArgumentNullException">Thrown if connectionString is null or empty</exception>
 5202    public EtcdClient(
 5203        string connectionString,
 5204        Action<SslClientAuthenticationOptions> configureSslOptions,
 5205        int port = 2379,
 5206        string serverName = DefaultServerName,
 5207        Action<GrpcChannelOptions> configureChannelOptions = null,
 5208        Interceptor[] interceptors = null
 5209    )
 5210    {
 211        // Param check
 5212        if (string.IsNullOrWhiteSpace(connectionString))
 0213        {
 0214            throw new ArgumentNullException(nameof(connectionString));
 215        }
 216
 217        // Param sanitization
 5218        interceptors ??= Array.Empty<Interceptor>();
 219
 5220        var channelFactory = new GrpcChannelFactory();
 221
 222        // Use SSL credentials when SSL options configuration is provided
 5223        var credentials =
 5224            configureSslOptions != null ? new SslCredentials() : ChannelCredentials.Insecure;
 225
 5226        _channel = channelFactory.CreateChannel(
 5227            connectionString,
 5228            port,
 5229            serverName,
 5230            credentials,
 5231            options =>
 5232            {
 5233                configureChannelOptions?.Invoke(options);
 5234                _authHttpHandler = new AuthenticationHttpHandler(
 5235                    RequestTokenAsync,
 5236                    options.HttpHandler!
 5237                );
 5238                options.HttpHandler = _authHttpHandler;
 5239            },
 5240            configureSslOptions
 5241        );
 5242        CallInvoker callInvoker =
 5243            interceptors.Length > 0
 5244                ? _channel.Intercept(interceptors)
 5245                : _channel.CreateCallInvoker();
 246
 247        // Setup Connection
 5248        _connection = new Connection(callInvoker);
 249
 250        // Create the watch call factory
 5251        _watchCallFactory = new AsyncStreamCallFactory<WatchRequest, WatchResponse>(
 5252            (headers, deadline, cancellationToken) =>
 0253                _connection.WatchClient.Watch(headers, deadline, cancellationToken)
 5254        );
 255
 256        // Initialize the watch manager
 5257        _watchManager = new WatchManager(
 5258            (headers, deadline, cancellationToken) =>
 0259                _watchCallFactory.CreateDuplexStreamingCall(headers, deadline, cancellationToken)
 5260        );
 5261    }
 262
 263    /// <summary>
 264    ///     Initializes a new instance of the <see cref="EtcdClient" /> class with a connection string and credentials.
 265    /// </summary>
 266    /// <param name="connectionString">The connection string for etcd</param>
 267    /// <param name="username">The username for authentication</param>
 268    /// <param name="password">The password for authentication</param>
 269    /// <param name="port">The port to connect to</param>
 270    /// <param name="serverName">The server name</param>
 271    /// <param name="configureChannelOptions">Function to configure channel options</param>
 272    /// <param name="tokenCacheDuration">The duration to cache requested tokens from etcd</param>
 273    /// <exception cref="ArgumentNullException">Thrown if connectionString is null or empty</exception>
 274    public EtcdClient(
 275        string connectionString,
 276        string username,
 277        string password,
 278        int port = 2379,
 279        string serverName = DefaultServerName,
 280        Action<GrpcChannelOptions> configureChannelOptions = null,
 281        TimeSpan? tokenCacheDuration = null
 282    )
 15283        : this(connectionString, port, serverName, configureChannelOptions)
 15284    {
 285        // Validate and set credentials
 15286        if (string.IsNullOrWhiteSpace(username))
 3287        {
 3288            throw new ArgumentNullException(nameof(username));
 289        }
 290
 12291        if (string.IsNullOrWhiteSpace(password))
 3292        {
 3293            throw new ArgumentNullException(nameof(password));
 294        }
 295
 9296        if (tokenCacheDuration.HasValue)
 2297            _tokenCacheDuration = tokenCacheDuration.Value;
 298
 9299        _credentials = new EtcdCredentials(username, password);
 9300    }
 301
 302    /// <summary>
 303    ///     Initializes a new instance of the <see cref="EtcdClient" /> class for testing.
 304    /// </summary>
 305    /// <param name="connection">The connection to use</param>
 306    /// <param name="watchManager">The watch manager to use</param>
 307    /// <exception cref="ArgumentNullException">Thrown if connection or watchManager is null</exception>
 49308    public EtcdClient(IConnection connection, IWatchManager watchManager = null)
 49309    {
 49310        ArgumentNullException.ThrowIfNull(connection);
 311
 48312        _connection = connection;
 313
 48314        if (watchManager != null)
 47315        {
 47316            _watchManager = watchManager;
 47317        }
 318        else
 1319        {
 320            // Create the watch call factory
 1321            _watchCallFactory = new AsyncStreamCallFactory<WatchRequest, WatchResponse>(
 1322                (headers, deadline, cancellationToken) =>
 0323                    _connection.WatchClient.Watch(headers, deadline, cancellationToken)
 1324            );
 325
 326            // Initialize the watch manager with default implementation
 1327            _watchManager = new WatchManager(
 1328                (headers, deadline, cancellationToken) =>
 0329                    _watchCallFactory.CreateDuplexStreamingCall(
 0330                        headers,
 0331                        deadline,
 0332                        cancellationToken
 0333                    )
 1334            );
 1335        }
 48336    }
 337
 338    #endregion
 339
 340    #region Authentication
 341
 342    /// <summary>
 343    ///     Sets the credentials for automatic authentication with etcd.
 344    ///     When credentials are set, all subsequent requests will automatically include the authentication token.
 345    /// </summary>
 346    /// <param name="username">The username for authentication</param>
 347    /// <param name="password">The password for authentication</param>
 348    /// <param name="tokenCacheDuration">The duration to cache requested tokens from etcd</param>
 349    /// <exception cref="ArgumentNullException">Thrown if username or password is null or empty</exception>
 350    /// <exception cref="InvalidOperationException">
 351    ///     Thrown when the client was created from a <see cref="CallInvoker" />, which has no
 352    ///     channel for the library to attach authentication to. Supply credentials on that path
 353    ///     yourself via the CallInvoker.
 354    /// </exception>
 355    public void SetCredentials(
 356        string username,
 357        string password,
 358        TimeSpan? tokenCacheDuration = null
 359    )
 50360    {
 50361        if (string.IsNullOrWhiteSpace(username))
 0362        {
 0363            throw new ArgumentNullException(nameof(username));
 364        }
 365
 50366        if (string.IsNullOrWhiteSpace(password))
 0367        {
 0368            throw new ArgumentNullException(nameof(password));
 369        }
 370
 50371        EnsureAuthenticationSupported();
 372
 49373        if (tokenCacheDuration.HasValue)
 0374            _tokenCacheDuration = tokenCacheDuration.Value;
 375
 49376        _credentials = new EtcdCredentials(username, password);
 377
 378        // Purge any token cached under the previous credentials so the next request re-auths.
 49379        _authHttpHandler.InvalidateToken();
 49380    }
 381
 382    /// <summary>
 383    ///     Clears the current credentials if set and invalidates any cached token.
 384    /// </summary>
 385    /// <exception cref="InvalidOperationException">
 386    ///     Thrown when the client was created from a <see cref="CallInvoker" /> and therefore
 387    ///     does not manage authentication.
 388    /// </exception>
 389    public void ClearCredentials()
 17390    {
 17391        EnsureAuthenticationSupported();
 392
 16393        _credentials = null;
 16394        _authHttpHandler.InvalidateToken();
 16395    }
 396
 397    /// <summary>
 398    ///     Guards the credential APIs against the CallInvoker overload, where no channel â€” and thus
 399    ///     no <see cref="AuthenticationHttpHandler" /> â€” exists to carry the auth token. Failing
 400    ///     here turns a silent no-op (requests going out unauthenticated) into an explicit error.
 401    /// </summary>
 402    private void EnsureAuthenticationSupported()
 67403    {
 67404        if (_authHttpHandler is null)
 2405        {
 2406            throw new InvalidOperationException(
 2407                "This EtcdClient was created from a CallInvoker, which the library cannot attach "
 2408                    + "authentication to. Construct the client with a connection string to use "
 2409                    + "SetCredentials/ClearCredentials, or attach credentials to the CallInvoker yourself."
 2410            );
 411        }
 65412    }
 413
 414    private async Task<(string token, TimeSpan cacheDuration)?> RequestTokenAsync(
 415        CancellationToken cancellationToken
 416    )
 151417    {
 151418        EtcdCredentials cred = _credentials;
 151419        if (cred is null)
 94420            return null;
 421
 57422        AuthenticateResponse response = await _connection
 57423            .AuthClient.AuthenticateAsync(
 57424                new AuthenticateRequest
 57425                {
 57426                    Name = cred.Username,
 57427                    Password = cred.Password,
 57428                },
 57429                cancellationToken: cancellationToken
 57430            )
 57431            .ConfigureAwait(false);
 432
 41433        return (response.Token, _tokenCacheDuration);
 135434    }
 435
 436    #endregion
 437
 438    #region IDisposable Support
 439
 440    private bool _disposed;
 441
 442    /// <summary>
 443    ///     Disposes the resources used by this instance
 444    /// </summary>
 445    /// <param name="disposing">Whether to dispose managed resources</param>
 446    protected virtual void Dispose(bool disposing)
 122447    {
 122448        if (!_disposed)
 102449        {
 102450            if (disposing)
 102451            {
 452                // Dispose managed resources
 102453                _channel?.Dispose();
 102454                _watchManager?.Dispose();
 102455            }
 456
 102457            _disposed = true;
 102458        }
 122459    }
 460
 461    /// <summary>
 462    ///     Disposes the resources used by this instance
 463    /// </summary>
 464    public void Dispose()
 122465    {
 122466        Dispose(true);
 122467        GC.SuppressFinalize(this);
 122468    }
 469
 470    #endregion
 471}

/home/runner/work/dotnet-etcd/dotnet-etcd/dotnet-etcd/kvClient.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Threading;
 4using System.Threading.Tasks;
 5using Etcdserverpb;
 6using Google.Protobuf;
 7using Grpc.Core;
 8
 9namespace dotnet_etcd;
 10
 11public partial class EtcdClient
 12{
 13    /// <summary>
 14    ///     Get the etcd response for a specified RangeRequest
 15    /// </summary>
 16    /// <param name="request">The request to send to the server.</param>
 17    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 18    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 19    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 20    /// <returns>The etcd response for the specified request</returns>
 21    public RangeResponse Get(RangeRequest request, Metadata headers = null, DateTime? deadline = null,
 3622        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.KVClient
 3623        .Range(request, headers, deadline, cancellationToken));
 24
 25    /// <summary>
 26    ///     Get the etcd response for a specified key
 27    /// </summary>
 28    /// <param name="key">Key for which value need to be fetched</param>
 29    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 30    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 31    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 32    /// <returns>The etcd response for the specified key</returns>
 33    public RangeResponse Get(string key, Metadata headers = null, DateTime? deadline = null,
 834        CancellationToken cancellationToken = default) => Get(new RangeRequest { Key = ByteString.CopyFromUtf8(key) },
 835        headers, deadline, cancellationToken);
 36
 37    /// <summary>
 38    ///     Get the etcd response for a specified key in async
 39    /// </summary>
 40    /// <param name="request">The request to send to the server.</param>
 41    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 42    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 43    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 44    /// <returns>The etcd response for the specified request</returns>
 45    public async Task<RangeResponse> GetAsync(RangeRequest request, Metadata headers = null,
 46        DateTime? deadline = null,
 7247        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 7248        .KVClient
 7249        .RangeAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 50
 51    /// <summary>
 52    ///     Get the etcd response for a specified key in async
 53    /// </summary>
 54    /// <param name="key">Key for which value need to be fetched</param>
 55    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 56    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 57    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 58    /// <returns>The etcd response for the specified key</returns>
 59    public async Task<RangeResponse> GetAsync(string key, Metadata headers = null,
 60        DateTime? deadline = null,
 61        CancellationToken cancellationToken = default) =>
 2262        await GetAsync(new RangeRequest { Key = ByteString.CopyFromUtf8(key) }, headers, deadline, cancellationToken)
 2263            .ConfigureAwait(false);
 64
 65    /// <summary>
 66    ///     Get the value for a specified key
 67    /// </summary>
 68    /// <param name="key">Key for which value need to be fetched</param>
 69    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 70    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 71    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 72    /// <returns>The value for the specified key</returns>
 73    public string GetVal(string key, Metadata headers = null, DateTime? deadline = null,
 74        CancellationToken cancellationToken = default)
 475    {
 476        RangeResponse rangeResponse = Get(key, headers, deadline, cancellationToken);
 477        return rangeResponse.Count != 0 ? rangeResponse.Kvs[0].Value.ToStringUtf8().Trim() : string.Empty;
 478    }
 79
 80    /// <summary>
 81    ///     Get the value for a specified key in async
 82    /// </summary>
 83    /// <param name="key">Key for which value need to be fetched</param>
 84    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 85    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 86    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 87    /// <returns>The value for the specified key</returns>
 88    public async Task<string> GetValAsync(string key, Metadata headers = null, DateTime? deadline = null,
 89        CancellationToken cancellationToken = default)
 790    {
 791        RangeResponse rangeResponse = await GetAsync(key, headers, deadline, cancellationToken).ConfigureAwait(false);
 792        return rangeResponse.Count != 0 ? rangeResponse.Kvs[0].Value.ToStringUtf8().Trim() : string.Empty;
 793    }
 94
 95    /// <summary>
 96    ///     Gets the range of keys with the specified prefix
 97    /// </summary>
 98    /// <param name="prefixKey">Prefix key</param>
 99    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 100    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 101    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 102    /// <returns>RangeResponse containing range of key-values</returns>
 103    public RangeResponse GetRange(string prefixKey, Metadata headers = null, DateTime? deadline = null,
 104        CancellationToken cancellationToken = default)
 6105    {
 6106        return Get(
 6107            new RangeRequest
 6108            {
 6109                Key = GetStringByteForRangeRequests(prefixKey), RangeEnd = GetRangeEnd(ByteString.CopyFromUtf8(prefixKey
 6110            }, headers, deadline, cancellationToken);
 6111    }
 112
 113    /// <summary>
 114    ///     Gets the range of keys with the specified prefix in async
 115    /// </summary>
 116    /// <param name="prefixKey">Prefix key</param>
 117    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 118    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 119    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 120    /// <returns>RangeResponse containing range of key-values</returns>
 121    public async Task<RangeResponse> GetRangeAsync(string prefixKey, Metadata headers = null,
 122        DateTime? deadline = null,
 123        CancellationToken cancellationToken = default)
 3124    {
 3125        return await GetAsync(
 3126            new RangeRequest
 3127            {
 3128                Key = GetStringByteForRangeRequests(prefixKey), RangeEnd = GetRangeEnd(ByteString.CopyFromUtf8(prefixKey
 3129            }, headers, deadline, cancellationToken).ConfigureAwait(false);
 3130    }
 131
 132    /// <summary>
 133    ///     Gets the range of keys with the specified prefix
 134    /// </summary>
 135    /// <param name="prefixKey">Prefix key</param>
 136    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 137    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 138    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 139    /// <returns>Dictionary containing range of key-values</returns>
 140    public IDictionary<string, string> GetRangeVal(string prefixKey, Metadata headers = null,
 141        DateTime? deadline = null,
 142        CancellationToken cancellationToken = default)
 2143    {
 2144        return RangeRespondToDictionary(Get(
 2145            new RangeRequest
 2146            {
 2147                Key = GetStringByteForRangeRequests(prefixKey), RangeEnd = GetRangeEnd(ByteString.CopyFromUtf8(prefixKey
 2148            }, headers, deadline, cancellationToken));
 2149    }
 150
 151    /// <summary>
 152    ///     Gets the range of keys with the specified prefix in async
 153    /// </summary>
 154    /// <param name="prefixKey">Prefix key</param>
 155    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 156    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 157    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 158    /// <returns>Dictionary containing range of key-values</returns>
 159    public async Task<IDictionary<string, string>> GetRangeValAsync(string prefixKey,
 160        Metadata headers = null, DateTime? deadline = null,
 161        CancellationToken cancellationToken = default)
 1162    {
 1163        return RangeRespondToDictionary(
 1164            await GetAsync(
 1165                new RangeRequest
 1166                {
 1167                    Key = GetStringByteForRangeRequests(prefixKey), RangeEnd = GetRangeEnd(ByteString.CopyFromUtf8(prefi
 1168                }, headers, deadline, cancellationToken).ConfigureAwait(false));
 1169    }
 170
 171    /// <summary>
 172    ///     Sets the key value in etcd
 173    /// </summary>
 174    /// <param name="request">The request to send to the server.</param>
 175    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 176    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 177    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 178    /// <returns>The response received from the server.</returns>
 179    public PutResponse Put(PutRequest request, Metadata headers = null, DateTime? deadline = null,
 19180        CancellationToken cancellationToken = default) => CallEtcd(connection =>
 38181        connection.KVClient.Put(request, headers, deadline, cancellationToken));
 182
 183    /// <summary>
 184    ///     Sets the key value in etcd
 185    /// </summary>
 186    /// <param name="key">Key for which value need to be set</param>
 187    /// <param name="val">Value corresponding the key</param>
 188    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 189    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 190    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 191    /// <returns>The response received from the server.</returns>
 192    public PutResponse Put(string key, string val, Metadata headers = null, DateTime? deadline = null,
 193        CancellationToken cancellationToken = default) =>
 17194        Put(new PutRequest { Key = ByteString.CopyFromUtf8(key), Value = ByteString.CopyFromUtf8(val) }, headers,
 17195            deadline, cancellationToken);
 196
 197    /// <summary>
 198    ///     Sets the key value in etcd in async
 199    /// </summary>
 200    /// <param name="request">The request to send to the server.</param>
 201    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 202    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 203    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 204    /// <returns>The response received from the server.</returns>
 205    public async Task<PutResponse> PutAsync(PutRequest request, Metadata headers = null,
 206        DateTime? deadline = null,
 136207        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 136208        .KVClient
 136209        .PutAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 210
 211
 212    /// <summary>
 213    ///     Sets the key value in etcd in async
 214    /// </summary>
 215    /// <param name="key">Key for which value need to be set</param>
 216    /// <param name="val">Value corresponding the key</param>
 217    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 218    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 219    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 220    /// <returns>The response received from the server.</returns>
 221    public async Task<PutResponse> PutAsync(string key, string val, Metadata headers = null,
 222        DateTime? deadline = null,
 223        CancellationToken cancellationToken = default) =>
 64224        await PutAsync(new PutRequest { Key = ByteString.CopyFromUtf8(key), Value = ByteString.CopyFromUtf8(val) },
 64225            headers, deadline, cancellationToken).ConfigureAwait(false);
 226
 227    /// <summary>
 228    ///     Delete the specified key in etcd
 229    /// </summary>
 230    /// <param name="request">The request to send to the server.</param>
 231    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 232    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 233    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 234    /// <returns>The response received from the server.</returns>
 235    public DeleteRangeResponse Delete(DeleteRangeRequest request, Metadata headers = null,
 236        DateTime? deadline = null,
 32237        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.KVClient
 32238        .DeleteRange(request, headers, deadline, cancellationToken));
 239
 240    /// <summary>
 241    ///     Delete the specified key in etcd
 242    /// </summary>
 243    /// <param name="key">Key which needs to be deleted</param>
 244    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 245    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 246    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 247    /// <returns>The response received from the server.</returns>
 248    public DeleteRangeResponse Delete(string key, Metadata headers = null, DateTime? deadline = null,
 11249        CancellationToken cancellationToken = default) => Delete(
 11250        new DeleteRangeRequest { Key = ByteString.CopyFromUtf8(key) }, headers, deadline, cancellationToken);
 251
 252
 253    /// <summary>
 254    ///     Delete the specified key in etcd in async
 255    /// </summary>
 256    /// <param name="request">The request to send to the server.</param>
 257    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 258    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 259    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 260    /// <returns>The response received from the server.</returns>
 261    public async Task<DeleteRangeResponse> DeleteAsync(DeleteRangeRequest request,
 262        Metadata headers = null, DateTime? deadline = null,
 134263        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 134264        .KVClient
 134265        .DeleteRangeAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 266
 267    /// <summary>
 268    ///     Delete the specified key in etcd in async
 269    /// </summary>
 270    /// <param name="key">Key which needs to be deleted</param>
 271    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 272    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 273    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 274    /// <returns>The response received from the server.</returns>
 275    public async Task<DeleteRangeResponse> DeleteAsync(string key, Metadata headers = null,
 276        DateTime? deadline = null,
 277        CancellationToken cancellationToken = default) =>
 29278        await DeleteAsync(new DeleteRangeRequest { Key = ByteString.CopyFromUtf8(key) }, headers, deadline,
 29279            cancellationToken).ConfigureAwait(false);
 280
 281    /// <summary>
 282    ///     Deletes all keys with the specified prefix
 283    /// </summary>
 284    /// <param name="prefixKey">Common prefix of all keys that need to be deleted</param>
 285    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 286    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 287    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 288    /// <returns>The response received from the server.</returns>
 289    public DeleteRangeResponse DeleteRange(string prefixKey, Metadata headers = null,
 290        DateTime? deadline = null,
 291        CancellationToken cancellationToken = default)
 3292    {
 3293        return Delete(
 3294            new DeleteRangeRequest
 3295            {
 3296                Key = ByteString.CopyFromUtf8(prefixKey), RangeEnd = GetRangeEnd(ByteString.CopyFromUtf8(prefixKey))
 3297            }, headers, deadline, cancellationToken);
 3298    }
 299
 300    /// <summary>
 301    ///     Deletes all keys with the specified prefix in async
 302    /// </summary>
 303    /// <param name="prefixKey">Commin prefix of all keys that need to be deleted</param>
 304    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 305    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 306    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 307    /// <returns>The response received from the server.</returns>
 308    public async Task<DeleteRangeResponse> DeleteRangeAsync(string prefixKey, Metadata headers = null,
 309        DateTime? deadline = null,
 310        CancellationToken cancellationToken = default)
 37311    {
 37312        return await DeleteAsync(
 37313            new DeleteRangeRequest
 37314            {
 37315                Key = ByteString.CopyFromUtf8(prefixKey), RangeEnd = GetRangeEnd(ByteString.CopyFromUtf8(prefixKey))
 37316            }, headers, deadline, cancellationToken).ConfigureAwait(false);
 37317    }
 318
 319    /// <summary>
 320    ///     Txn processes multiple requests in a single transaction.
 321    ///     A txn request increments the revision of the key-value store
 322    ///     and generates events with the same revision for every completed request.
 323    ///     It is not allowed to modify the same key several times within one txn.
 324    /// </summary>
 325    /// <param name="request">The request to send to the server.</param>
 326    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 327    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 328    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 329    /// <returns>The response received from the server.</returns>
 330    public TxnResponse Transaction(TxnRequest request, Metadata headers = null, DateTime? deadline = null,
 2331        CancellationToken cancellationToken = default) => CallEtcd(connection =>
 4332        connection.KVClient.Txn(request, headers, deadline, cancellationToken));
 333
 334    /// <summary>
 335    ///     Txn processes multiple requests in a single transaction in async.
 336    ///     A txn request increments the revision of the key-value store
 337    ///     and generates events with the same revision for every completed request.
 338    ///     It is not allowed to modify the same key several times within one txn.
 339    /// </summary>
 340    /// <param name="request">The request to send to the server.</param>
 341    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 342    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 343    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 344    /// <returns>The response received from the server.</returns>
 345    public async Task<TxnResponse> TransactionAsync(TxnRequest request, Metadata headers = null,
 346        DateTime? deadline = null,
 6347        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 6348        .KVClient
 6349        .TxnAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 350
 351    /// <summary>
 352    ///     Compact compacts the event history in the etcd key-value store. The key-value
 353    ///     store should be periodically compacted or the event history will continue to grow
 354    ///     indefinitely.
 355    /// </summary>
 356    /// <param name="request">The request to send to the server.</param>
 357    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 358    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 359    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 360    /// <returns>The response received from the server.</returns>
 361    public CompactionResponse Compact(CompactionRequest request, Metadata headers = null,
 362        DateTime? deadline = null,
 2363        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.KVClient
 2364        .Compact(request, headers, deadline, cancellationToken));
 365
 366    /// <summary>
 367    ///     Compact compacts the event history in the etcd key-value store in async. The key-value
 368    ///     store should be periodically compacted or the event history will continue to grow
 369    ///     indefinitely.
 370    /// </summary>
 371    /// <param name="request">The request to send to the server.</param>
 372    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 373    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 374    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 375    /// <returns>The response received from the server.</returns>
 376    public async Task<CompactionResponse> CompactAsync(CompactionRequest request, Metadata headers = null,
 377        DateTime? deadline = null,
 2378        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 2379        .KVClient
 2380        .CompactAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 381
 382    /// <summary>
 383    ///     RangeStream gets the keys in the range from the key-value store, streamed back in chunks
 384    ///     instead of a single response. <paramref name="method" /> is invoked once per chunk, in order,
 385    ///     with that chunk's partial <see cref="RangeResponse" />: each chunk carries a disjoint slice of
 386    ///     the keys, and only the final chunk carries <c>Header</c>, <c>More</c> and <c>Count</c>.
 387    ///     Requires etcd 3.7 or later; older servers fail the call with <see cref="StatusCode.Unimplemented" />.
 388    /// </summary>
 389    /// <param name="request">The request to send to the server.</param>
 390    /// <param name="method">Invoked once per chunk with that chunk's partial range response.</param>
 391    /// <param name="cancellationToken">A token for canceling the stream.</param>
 392    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 393    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 394    public async Task RangeStream(RangeRequest request, Action<RangeResponse> method,
 6395        CancellationToken cancellationToken, Metadata headers = null, DateTime? deadline = null) => await CallEtcdAsync(
 6396        async connection =>
 6397        {
 6398            using (AsyncServerStreamingCall<RangeStreamResponse> stream = connection
 6399                       .KVClient.RangeStream(request, headers, deadline, cancellationToken))
 6400            {
 14401                while (await stream.ResponseStream.MoveNext(cancellationToken).ConfigureAwait(false))
 8402                {
 8403                    RangeResponse chunk = stream.ResponseStream.Current.RangeResponse;
 8404                    if (chunk != null)
 7405                    {
 7406                        method(chunk);
 7407                    }
 8408                }
 6409            }
 12410        }).ConfigureAwait(false);
 411
 412    /// <summary>
 413    ///     RangeStreamAsync gets the keys in the range from the key-value store over a stream and merges
 414    ///     the chunks into one <see cref="RangeResponse" />. The result is the same as
 415    ///     <see cref="GetAsync(RangeRequest, Metadata, DateTime?, CancellationToken)" /> would return, but the
 416    ///     server never has to materialise the whole range in a single message, so it suits ranges that
 417    ///     would otherwise exceed the gRPC message size limit. Requires etcd 3.7 or later.
 418    /// </summary>
 419    /// <param name="request">The request to send to the server.</param>
 420    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 421    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 422    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 423    /// <returns>All chunks merged into a single range response.</returns>
 424    public async Task<RangeResponse> RangeStreamAsync(RangeRequest request, Metadata headers = null,
 425        DateTime? deadline = null, CancellationToken cancellationToken = default)
 3426    {
 3427        RangeResponse merged = new();
 428        // etcd documents the stream as "proto.Merge of all chunks == the unary RangeResponse":
 429        // repeated Kvs concatenate, and Header/More/Count come from the final chunk.
 3430        await RangeStream(request, merged.MergeFrom, cancellationToken, headers, deadline).ConfigureAwait(false);
 3431        return merged;
 3432    }
 433}

/home/runner/work/dotnet-etcd/dotnet-etcd/dotnet-etcd/leaseClient.cs

#LineLine coverage
 1using System;
 2using System.IO;
 3using System.Threading;
 4using System.Threading.Tasks;
 5using dotnet_etcd.interfaces;
 6using Etcdserverpb;
 7using Grpc.Core;
 8
 9namespace dotnet_etcd;
 10
 11public partial class EtcdClient
 12{
 13    /// <summary>
 14    ///     LeaseGrant creates a lease which expires if the server does not receive a keepAlive
 15    ///     within a given time to live period. All keys attached to the lease will be expired and
 16    ///     deleted if the lease expires. Each expired key generates a delete event in the event history.
 17    /// </summary>
 18    /// <param name="request">The request to send to the server.</param>
 19    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 20    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 21    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 22    /// <returns>The response received from the server.</returns>
 23    public LeaseGrantResponse LeaseGrant(LeaseGrantRequest request, Metadata headers = null,
 24        DateTime? deadline = null,
 2225        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.LeaseClient
 2226        .LeaseGrant(request, headers, deadline, cancellationToken));
 27
 28    /// <summary>
 29    ///     LeaseGrant creates a lease in async which expires if the server does not receive a keepAlive
 30    ///     within a given time to live period. All keys attached to the lease will be expired and
 31    ///     deleted if the lease expires. Each expired key generates a delete event in the event history.
 32    /// </summary>
 33    /// <param name="request">The request to send to the server.</param>
 34    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 35    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 36    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 37    /// <returns>The response received from the server.</returns>
 38    public async Task<LeaseGrantResponse> LeaseGrantAsync(LeaseGrantRequest request,
 39        Metadata headers = null, DateTime? deadline = null,
 2840        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 2841        .LeaseClient
 2842        .LeaseGrantAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 43
 44    /// <summary>
 45    ///     LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.
 46    /// </summary>
 47    /// <param name="request">The request to send to the server.</param>
 48    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 49    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 50    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 51    /// <returns>The response received from the server.</returns>
 52    public LeaseRevokeResponse LeaseRevoke(LeaseRevokeRequest request, Metadata headers = null,
 53        DateTime? deadline = null,
 2254        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.LeaseClient
 2255        .LeaseRevoke(request, headers, deadline, cancellationToken));
 56
 57    /// <summary>
 58    ///     LeaseRevoke revokes a lease in async. All keys attached to the lease will expire and be deleted.
 59    /// </summary>
 60    /// <param name="request">The request to send to the server.</param>
 61    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 62    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 63    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 64    /// <returns>The response received from the server.</returns>
 65    public async Task<LeaseRevokeResponse> LeaseRevokeAsync(LeaseRevokeRequest request,
 66        Metadata headers = null, DateTime? deadline = null,
 2667        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 2668        .LeaseClient
 2669        .LeaseRevokeAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 70
 71    /// <summary>
 72    ///     LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
 73    ///     to the server and streaming keep alive responses from the server to the client.
 74    /// </summary>
 75    /// <param name="cancellationTokenSource">
 76    ///     Cancellation token source that reflects communication status between server and
 77    ///     client.
 78    /// </param>
 79    /// <param name="leaseId">Granted lease identifier. <see cref="LeaseGrant" /> and <see cref="LeaseGrantAsync" /></pa
 80    /// <param name="keepAliveTimeout">Time to the next communication with Etcd server in milliseconds.</param>
 81    /// <param name="communicationTimeout">Time to wait response from Etcd server in milliseconds.</param>
 82    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 83    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 84    public Task LeaseKeepAlive(CancellationTokenSource cancellationTokenSource, long leaseId,
 85        int keepAliveTimeout = 1000, int? communicationTimeout = null, Metadata headers = null,
 886        DateTime? deadline = null) => CallEtcdAsync(connection =>
 887    {
 888        ArgumentNullException.ThrowIfNull(cancellationTokenSource);
 789        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(keepAliveTimeout);
 690        if (communicationTimeout.HasValue)
 291        {
 292            ArgumentOutOfRangeException.ThrowIfNegativeOrZero(communicationTimeout.Value, nameof(communicationTimeout));
 093        }
 894
 495        CancellationToken cancellationToken = cancellationTokenSource.Token;
 496        int communicationTimeoutInMilliseconds = communicationTimeout ?? keepAliveTimeout / 2;
 897
 898        async ValueTask WriteAsync(AsyncDuplexStreamingCall<LeaseKeepAliveRequest, LeaseKeepAliveResponse> leaser,
 899            LeaseKeepAliveRequest request, int timeoutInMilliseconds, CancellationToken cancellationToken)
 7100        {
 8101            // communication timeout
 7102            using CancellationTokenSource cancellationTokenSource =
 7103                CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
 7104            cancellationTokenSource.CancelAfter(timeoutInMilliseconds);
 8105
 7106            await leaser.RequestStream.WriteAsync(request, cancellationTokenSource.Token)
 7107                .ConfigureAwait(false);
 7108        }
 8109
 8110        async ValueTask<bool> MoveNextAsync(
 8111            AsyncDuplexStreamingCall<LeaseKeepAliveRequest, LeaseKeepAliveResponse> leaser, int timeoutInMilliseconds,
 8112            CancellationToken cancellationToken)
 7113        {
 8114            // communication timeout
 7115            using CancellationTokenSource cancellationTokenSource =
 7116                CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
 7117            cancellationTokenSource.CancelAfter(timeoutInMilliseconds);
 8118
 7119            return await leaser.ResponseStream.MoveNext(cancellationTokenSource.Token)
 7120                .ConfigureAwait(false);
 7121        }
 8122
 8123        AsyncDuplexStreamingCall<LeaseKeepAliveRequest, LeaseKeepAliveResponse> LeaseKeepAlive(IConnection connection,
 8124            int timeoutInMilliseconds, CancellationToken cancellationToken)
 4125        {
 8126            // communication timeout
 4127            using CancellationTokenSource cancellationTokenSource =
 4128                CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
 4129            cancellationTokenSource.CancelAfter(timeoutInMilliseconds);
 8130
 4131            return connection.LeaseClient.LeaseKeepAlive(headers, deadline, cancellationTokenSource.Token);
 4132        }
 8133
 8134        async Task KeepAliveAsync()
 4135        {
 4136            LeaseKeepAliveRequest request = new() { ID = leaseId };
 8137
 8138            try
 4139            {
 4140                using AsyncDuplexStreamingCall<LeaseKeepAliveRequest, LeaseKeepAliveResponse> leaser =
 4141                    LeaseKeepAlive(connection, communicationTimeoutInMilliseconds, cancellationToken);
 8142
 7143                while (!cancellationToken.IsCancellationRequested)
 7144                {
 7145                    await WriteAsync(leaser, request, communicationTimeoutInMilliseconds, cancellationToken)
 7146                        .ConfigureAwait(false);
 8147
 7148                    if (!await MoveNextAsync(leaser, communicationTimeoutInMilliseconds, cancellationToken)
 7149                            .ConfigureAwait(false))
 2150                    {
 8151                        try
 2152                        {
 2153                            if (!cancellationTokenSource.IsCancellationRequested)
 2154                            {
 8155#if NET8_0_OR_GREATER
 2156                                await cancellationTokenSource.CancelAsync()
 2157                                    .ConfigureAwait(false);
 8158#else
 8159                                    cancellationTokenSource.Cancel();
 8160#endif
 2161                            }
 2162                        }
 8163                        finally
 2164                        {
 2165                            await leaser.RequestStream.CompleteAsync()
 2166                                .ConfigureAwait(false);
 2167                        }
 8168
 2169                        break;
 8170                    }
 8171
 5172                    LeaseKeepAliveResponse update = leaser.ResponseStream.Current;
 5173                    if (update.ID != leaseId || update.TTL == 0) // expired
 2174                    {
 8175                        try
 2176                        {
 2177                            if (!cancellationTokenSource.IsCancellationRequested)
 2178                            {
 8179#if NET8_0_OR_GREATER
 2180                                await cancellationTokenSource.CancelAsync()
 2181                                    .ConfigureAwait(false);
 8182#else
 8183                                    cancellationTokenSource.Cancel();
 8184#endif
 2185                            }
 2186                        }
 8187                        finally
 2188                        {
 2189                            await leaser.RequestStream.CompleteAsync()
 2190                                .ConfigureAwait(false);
 2191                        }
 8192
 2193                        break;
 8194                    }
 8195
 3196                    await Task.Delay(keepAliveTimeout, cancellationToken)
 3197                        .ConfigureAwait(false);
 3198                }
 4199            }
 8200            finally
 4201            {
 4202                if (!cancellationTokenSource.IsCancellationRequested)
 0203                {
 8204#if NET8_0_OR_GREATER
 0205                    await cancellationTokenSource.CancelAsync()
 0206                        .ConfigureAwait(false);
 8207#else
 8208                        cancellationTokenSource.Cancel();
 8209#endif
 0210                }
 4211            }
 8212        }
 8213
 4214        return Task.Run(KeepAliveAsync, cancellationToken);
 12215    });
 216
 217    /// <summary>
 218    ///     LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
 219    ///     to the server and streaming keep alive responses from the server to the client.
 220    /// </summary>
 221    /// <param name="leaseId"></param>
 222    /// <param name="cancellationToken"></param>
 3223    public async Task LeaseKeepAlive(long leaseId, CancellationToken cancellationToken) => await CallEtcdAsync(
 3224        async connection =>
 3225        {
 3226            using (AsyncDuplexStreamingCall<LeaseKeepAliveRequest, LeaseKeepAliveResponse> leaser =
 3227                   connection.LeaseClient.LeaseKeepAlive(cancellationToken: cancellationToken))
 3228            {
 3229                LeaseKeepAliveRequest request = new() { ID = leaseId };
 3230
 5231                while (true)
 5232                {
 5233                    cancellationToken.ThrowIfCancellationRequested();
 3234
 5235                    await leaser.RequestStream.WriteAsync(request).ConfigureAwait(false);
 5236                    if (!await leaser.ResponseStream.MoveNext(cancellationToken).ConfigureAwait(false))
 2237                    {
 2238                        await leaser.RequestStream.CompleteAsync().ConfigureAwait(false);
 2239                        throw new EndOfStreamException();
 3240                    }
 3241
 3242                    LeaseKeepAliveResponse update = leaser.ResponseStream.Current;
 3243                    if (update.ID != leaseId || update.TTL == 0) // expired
 1244                    {
 1245                        await leaser.RequestStream.CompleteAsync().ConfigureAwait(false);
 1246                        return;
 3247                    }
 3248
 2249                    await Task.Delay(TimeSpan.FromMilliseconds(update.TTL * 1000 / 3), cancellationToken)
 2250                        .ConfigureAwait(false);
 2251                }
 3252            }
 4253        }).ConfigureAwait(false);
 254
 255    /// <summary>
 256    ///     LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
 257    ///     to the server and streaming keep alive responses from the server to the client.
 258    /// </summary>
 259    /// <param name="request">The request to send to the server.</param>
 260    /// <param name="method"></param>
 261    /// <param name="cancellationToken"></param>
 262    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 263    public async Task LeaseKeepAlive(LeaseKeepAliveRequest request, Action<LeaseKeepAliveResponse> method,
 1264        CancellationToken cancellationToken, Metadata headers = null) => await CallEtcdAsync(async connection =>
 1265    {
 1266        using (AsyncDuplexStreamingCall<LeaseKeepAliveRequest, LeaseKeepAliveResponse> leaser =
 1267               connection.LeaseClient
 1268                   .LeaseKeepAlive(headers, cancellationToken: cancellationToken))
 1269        {
 1270            Task leaserTask = Task.Run(async () =>
 1271            {
 2272                while (await leaser.ResponseStream.MoveNext(cancellationToken).ConfigureAwait(false))
 1273                {
 1274                    LeaseKeepAliveResponse update = leaser.ResponseStream.Current;
 1275                    method(update);
 1276                }
 2277            }, cancellationToken);
 1278
 1279            await leaser.RequestStream.WriteAsync(request).ConfigureAwait(false);
 1280            await leaser.RequestStream.CompleteAsync().ConfigureAwait(false);
 1281            await leaserTask.ConfigureAwait(false);
 1282        }
 2283    }).ConfigureAwait(false);
 284
 285    /// <summary>
 286    ///     LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
 287    ///     to the server and streaming keep alive responses from the server to the client.
 288    /// </summary>
 289    /// <param name="request">The request to send to the server.</param>
 290    /// <param name="methods"></param>
 291    /// <param name="cancellationToken"></param>
 292    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 293    public async Task LeaseKeepAlive(LeaseKeepAliveRequest request, Action<LeaseKeepAliveResponse>[] methods,
 1294        CancellationToken cancellationToken, Metadata headers = null) => await CallEtcdAsync(async connection =>
 1295    {
 1296        using (AsyncDuplexStreamingCall<LeaseKeepAliveRequest, LeaseKeepAliveResponse> leaser =
 1297               connection.LeaseClient
 1298                   .LeaseKeepAlive(headers, cancellationToken: cancellationToken))
 1299        {
 1300            Task leaserTask = Task.Run(async () =>
 1301            {
 2302                while (await leaser.ResponseStream.MoveNext(cancellationToken).ConfigureAwait(false))
 1303                {
 1304                    LeaseKeepAliveResponse update = leaser.ResponseStream.Current;
 7305                    foreach (Action<LeaseKeepAliveResponse> method in methods)
 2306                    {
 2307                        method(update);
 2308                    }
 1309                }
 2310            }, cancellationToken);
 1311
 1312            await leaser.RequestStream.WriteAsync(request).ConfigureAwait(false);
 1313            await leaser.RequestStream.CompleteAsync().ConfigureAwait(false);
 1314            await leaserTask.ConfigureAwait(false);
 1315        }
 2316    }).ConfigureAwait(false);
 317
 318
 319    /// <summary>
 320    ///     LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
 321    ///     to the server and streaming keep alive responses from the server to the client.
 322    /// </summary>
 323    /// <param name="requests"></param>
 324    /// <param name="method"></param>
 325    /// <param name="cancellationToken"></param>
 326    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 327    public async Task LeaseKeepAlive(LeaseKeepAliveRequest[] requests, Action<LeaseKeepAliveResponse> method,
 1328        CancellationToken cancellationToken, Metadata headers = null) => await CallEtcdAsync(async connection =>
 1329    {
 1330        using (AsyncDuplexStreamingCall<LeaseKeepAliveRequest, LeaseKeepAliveResponse> leaser =
 1331               connection.LeaseClient
 1332                   .LeaseKeepAlive(headers, cancellationToken: cancellationToken))
 1333        {
 1334            Task leaserTask = Task.Run(async () =>
 1335            {
 2336                while (await leaser.ResponseStream.MoveNext(cancellationToken).ConfigureAwait(false))
 1337                {
 1338                    LeaseKeepAliveResponse update = leaser.ResponseStream.Current;
 1339                    method(update);
 1340                }
 2341            }, cancellationToken);
 1342
 7343            foreach (LeaseKeepAliveRequest request in requests)
 2344            {
 2345                await leaser.RequestStream.WriteAsync(request).ConfigureAwait(false);
 2346            }
 1347
 1348            await leaser.RequestStream.CompleteAsync().ConfigureAwait(false);
 1349            await leaserTask.ConfigureAwait(false);
 1350        }
 2351    }).ConfigureAwait(false);
 352
 353    /// <summary>
 354    ///     LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
 355    ///     to the server and streaming keep alive responses from the server to the client.
 356    /// </summary>
 357    /// <param name="requests"></param>
 358    /// <param name="methods"></param>
 359    /// <param name="cancellationToken"></param>
 360    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 361    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 362    public async Task LeaseKeepAlive(LeaseKeepAliveRequest[] requests, Action<LeaseKeepAliveResponse>[] methods,
 1363        CancellationToken cancellationToken, Metadata headers = null, DateTime? deadline = null) => await CallEtcdAsync(
 1364        async connection =>
 1365        {
 1366            using (AsyncDuplexStreamingCall<LeaseKeepAliveRequest, LeaseKeepAliveResponse> leaser =
 1367                   connection.LeaseClient
 1368                       .LeaseKeepAlive(headers, deadline, cancellationToken))
 1369            {
 1370                Task leaserTask = Task.Run(async () =>
 1371                {
 2372                    while (await leaser.ResponseStream.MoveNext(cancellationToken).ConfigureAwait(false))
 1373                    {
 1374                        LeaseKeepAliveResponse update = leaser.ResponseStream.Current;
 7375                        foreach (Action<LeaseKeepAliveResponse> method in methods)
 2376                        {
 2377                            method(update);
 2378                        }
 1379                    }
 2380                }, cancellationToken);
 1381
 7382                foreach (LeaseKeepAliveRequest request in requests)
 2383                {
 2384                    await leaser.RequestStream.WriteAsync(request).ConfigureAwait(false);
 2385                }
 1386
 1387                await leaser.RequestStream.CompleteAsync().ConfigureAwait(false);
 1388                await leaserTask.ConfigureAwait(false);
 1389            }
 2390        }).ConfigureAwait(false);
 391
 392    /// <summary>
 393    ///     LeaseTimeToLive retrieves lease information.
 394    /// </summary>
 395    /// <param name="request">The request to send to the server.</param>
 396    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 397    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 398    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 399    /// <returns>The response received from the server.</returns>
 400    public LeaseTimeToLiveResponse LeaseTimeToLive(LeaseTimeToLiveRequest request,
 401        Metadata headers = null, DateTime? deadline = null,
 6402        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.LeaseClient
 6403        .LeaseTimeToLive(request, headers, deadline, cancellationToken));
 404
 405    /// <summary>
 406    ///     LeaseTimeToLive retrieves lease information.
 407    /// </summary>
 408    /// <param name="request">The request to send to the server.</param>
 409    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 410    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 411    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 412    /// <returns>The call object.</returns>
 413    public async Task<LeaseTimeToLiveResponse> LeaseTimeToLiveAsync(LeaseTimeToLiveRequest request,
 414        Metadata headers = null, DateTime? deadline = null,
 10415        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 10416        .LeaseClient
 10417        .LeaseTimeToLiveAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 418
 419    /// <summary>
 420    ///     LeaseLeases lists all existing leases.
 421    /// </summary>
 422    /// <param name="request">The request to send to the server.</param>
 423    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 424    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 425    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 426    /// <returns>The response received from the server.</returns>
 427    public LeaseLeasesResponse LeaseLeases(LeaseLeasesRequest request, Metadata headers = null, DateTime? deadline = nul
 6428        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.LeaseClient
 6429        .LeaseLeases(request, headers, deadline, cancellationToken));
 430
 431    /// <summary>
 432    ///     LeaseLeasesAsync lists all existing leases in async.
 433    /// </summary>
 434    /// <param name="request">The request to send to the server.</param>
 435    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 436    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 437    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 438    /// <returns>The response received from the server.</returns>
 439    public async Task<LeaseLeasesResponse> LeaseLeasesAsync(LeaseLeasesRequest request, Metadata headers = null,
 440        DateTime? deadline = null,
 8441        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 8442        .LeaseClient
 8443        .LeaseLeasesAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 444
 445    /// <summary>
 446    ///     LeaseLeases lists all existing leases.
 447    /// </summary>
 448    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 449    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 450    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 451    /// <returns>The response received from the server.</returns>
 452    public LeaseLeasesResponse LeaseLeases(Metadata headers = null, DateTime? deadline = null,
 453        CancellationToken cancellationToken = default) =>
 2454        LeaseLeases(new LeaseLeasesRequest(), headers, deadline, cancellationToken);
 455
 456    /// <summary>
 457    ///     LeaseLeasesAsync lists all existing leases in async.
 458    /// </summary>
 459    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 460    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 461    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 462    /// <returns>The response received from the server.</returns>
 463    public async Task<LeaseLeasesResponse> LeaseLeasesAsync(Metadata headers = null, DateTime? deadline = null,
 464        CancellationToken cancellationToken = default) =>
 2465        await LeaseLeasesAsync(new LeaseLeasesRequest(), headers, deadline, cancellationToken).ConfigureAwait(false);
 466}

/home/runner/work/dotnet-etcd/dotnet-etcd/dotnet-etcd/lockClient.cs

#LineLine coverage
 1using System;
 2using System.Threading;
 3using System.Threading.Tasks;
 4using Google.Protobuf;
 5using Grpc.Core;
 6using V3Lockpb;
 7
 8namespace dotnet_etcd;
 9
 10public partial class EtcdClient
 11{
 12    /// <summary>
 13    ///     Lock acquires a distributed shared lock on a given named lock.
 14    ///     On success, it will return a unique key that exists so long as the
 15    ///     lock is held by the caller. This key can be used in conjunction with
 16    ///     transactions to safely ensure updates to etcd only occur while holding
 17    ///     lock ownership. The lock is held until Unlock is called on the key or the
 18    ///     lease associate with the owner expires.
 19    /// </summary>
 20    /// <param name="name">is the identifier for the distributed shared lock to be acquired.</param>
 21    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 22    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 23    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 24    /// <returns>The response received from the server.</returns>
 25    /// <remarks>
 26    ///     This overload sends no lease. etcd's lock server responds to an unset lease by creating a
 27    ///     session of its own with the default TTL of 60 seconds and immediately orphaning it, so
 28    ///     nothing keeps that lease alive: the lock is released roughly 60 seconds after it is
 29    ///     acquired, while the caller is still running and still believes it holds the lock. A
 30    ///     caller waiting on the same lock fails after the same interval with
 31    ///     "mutex: session is expired". Use the overload that takes an explicit lease.
 32    /// </remarks>
 33    [Obsolete(
 34        "Lock without an explicit lease releases the lock after ~60 seconds with no signal to the " +
 35        "caller, because etcd creates and orphans a session of its own. Grant a lease, keep it " +
 36        "alive with LeaseKeepAlive, and pass its id to Lock(name, leaseId, ...).")]
 37    public LockResponse Lock(string name, Metadata headers = null, DateTime? deadline = null,
 238        CancellationToken cancellationToken = default) => Lock(new LockRequest { Name = ByteString.CopyFromUtf8(name) },
 239        headers, deadline, cancellationToken);
 40
 41    /// <summary>
 42    ///     Lock acquires a distributed shared lock on a given named lock.
 43    ///     On success, it will return a unique key that exists so long as the
 44    ///     lock is held by the caller. This key can be used in conjunction with
 45    ///     transactions to safely ensure updates to etcd only occur while holding
 46    ///     lock ownership. The lock is held until Unlock is called on the key or the
 47    ///     lease associated with the owner expires.
 48    /// </summary>
 49    /// <param name="name">is the identifier for the distributed shared lock to be acquired.</param>
 50    /// <param name="leaseId">
 51    ///     The id of the lease that ownership of the lock is attached to. The lock is held for
 52    ///     exactly as long as this lease lives, so the caller is responsible for keeping it alive
 53    ///     (see <see cref="LeaseKeepAlive(CancellationTokenSource, long, int, int?, Metadata, DateTime?)" />);
 54    ///     when the lease expires or is revoked the lock is released automatically.
 55    /// </param>
 56    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 57    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 58    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 59    /// <returns>The response received from the server.</returns>
 60    public LockResponse Lock(string name, long leaseId, Metadata headers = null, DateTime? deadline = null,
 261        CancellationToken cancellationToken = default) => Lock(
 262        new LockRequest { Name = ByteString.CopyFromUtf8(name), Lease = leaseId },
 263        headers, deadline, cancellationToken);
 64
 65    /// <summary>
 66    ///     Lock acquires a distributed shared lock on a given named lock.
 67    ///     On success, it will return a unique key that exists so long as the
 68    ///     lock is held by the caller. This key can be used in conjunction with
 69    ///     transactions to safely ensure updates to etcd only occur while holding
 70    ///     lock ownership. The lock is held until Unlock is called on the key or the
 71    ///     lease associate with the owner expires.
 72    /// </summary>
 73    /// <param name="request">The request to send to the server</param>
 74    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 75    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 76    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 77    /// <returns>The response received from the server.</returns>
 78    public LockResponse Lock(LockRequest request, Metadata headers = null, DateTime? deadline = null,
 779        CancellationToken cancellationToken = default) => CallEtcd(connection =>
 1480        connection.LockClient.Lock(request, headers, deadline, cancellationToken));
 81
 82    /// <summary>
 83    ///     LockAsync acquires a distributed shared lock on a given named lock.
 84    ///     On success, it will return a unique key that exists so long as the
 85    ///     lock is held by the caller. This key can be used in conjunction with
 86    ///     transactions to safely ensure updates to etcd only occur while holding
 87    ///     lock ownership. The lock is held until Unlock is called on the key or the
 88    ///     lease associate with the owner expires.
 89    /// </summary>
 90    /// <param name="name">is the identifier for the distributed shared lock to be acquired.</param>
 91    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 92    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 93    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 94    /// <returns>The response received from the server.</returns>
 95    /// <remarks>
 96    ///     This overload sends no lease. etcd's lock server responds to an unset lease by creating a
 97    ///     session of its own with the default TTL of 60 seconds and immediately orphaning it, so
 98    ///     nothing keeps that lease alive: the lock is released roughly 60 seconds after it is
 99    ///     acquired, while the caller is still running and still believes it holds the lock. A
 100    ///     caller waiting on the same lock fails after the same interval with
 101    ///     "mutex: session is expired". Use the overload that takes an explicit lease.
 102    /// </remarks>
 103    [Obsolete(
 104        "LockAsync without an explicit lease releases the lock after ~60 seconds with no signal to " +
 105        "the caller, because etcd creates and orphans a session of its own. Grant a lease, keep it " +
 106        "alive with LeaseKeepAlive, and pass its id to LockAsync(name, leaseId, ...).")]
 107    public async Task<LockResponse> LockAsync(string name, Metadata headers = null,
 108        DateTime? deadline = null, CancellationToken cancellationToken = default) =>
 3109        await LockAsync(new LockRequest { Name = ByteString.CopyFromUtf8(name) }, headers, deadline, cancellationToken)
 3110            .ConfigureAwait(false);
 111
 112    /// <summary>
 113    ///     LockAsync acquires a distributed shared lock on a given named lock.
 114    ///     On success, it will return a unique key that exists so long as the
 115    ///     lock is held by the caller. This key can be used in conjunction with
 116    ///     transactions to safely ensure updates to etcd only occur while holding
 117    ///     lock ownership. The lock is held until Unlock is called on the key or the
 118    ///     lease associated with the owner expires.
 119    /// </summary>
 120    /// <param name="name">is the identifier for the distributed shared lock to be acquired.</param>
 121    /// <param name="leaseId">
 122    ///     The id of the lease that ownership of the lock is attached to. The lock is held for
 123    ///     exactly as long as this lease lives, so the caller is responsible for keeping it alive
 124    ///     (see <see cref="LeaseKeepAlive(CancellationTokenSource, long, int, int?, Metadata, DateTime?)" />);
 125    ///     when the lease expires or is revoked the lock is released automatically.
 126    /// </param>
 127    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 128    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 129    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 130    /// <returns>The response received from the server.</returns>
 131    public async Task<LockResponse> LockAsync(string name, long leaseId, Metadata headers = null,
 132        DateTime? deadline = null, CancellationToken cancellationToken = default) =>
 4133        await LockAsync(new LockRequest { Name = ByteString.CopyFromUtf8(name), Lease = leaseId },
 4134                headers, deadline, cancellationToken)
 4135            .ConfigureAwait(false);
 136
 137    /// <summary>
 138    ///     LockAsync acquires a distributed shared lock on a given named lock.
 139    ///     On success, it will return a unique key that exists so long as the
 140    ///     lock is held by the caller. This key can be used in conjunction with
 141    ///     transactions to safely ensure updates to etcd only occur while holding
 142    ///     lock ownership. The lock is held until Unlock is called on the key or the
 143    ///     lease associate with the owner expires.
 144    /// </summary>
 145    /// <param name="request">The request to send to the server</param>
 146    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 147    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 148    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 149    /// <returns>The response received from the server.</returns>
 150    public async Task<LockResponse> LockAsync(LockRequest request, Metadata headers = null,
 14151        DateTime? deadline = null, CancellationToken cancellationToken = default) => await CallEtcdAsync(
 28152        async connection => await connection.LockClient
 28153            .LockAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 154
 155    /// <summary>
 156    ///     Unlock takes a key returned by Lock and releases the hold on lock. The
 157    ///     next Lock caller waiting for the lock will then be woken up and given
 158    ///     ownership of the lock.
 159    /// </summary>
 160    /// <param name="key">the lock ownership key granted by Lock.</param>
 161    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 162    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 163    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 164    /// <returns>The response received from the server.</returns>
 165    public UnlockResponse Unlock(string key, Metadata headers = null, DateTime? deadline = null,
 166        CancellationToken cancellationToken = default) =>
 2167        Unlock(new UnlockRequest { Key = ByteString.CopyFromUtf8(key) }, headers, deadline, cancellationToken);
 168
 169    /// <summary>
 170    ///     Unlock takes a key returned by Lock and releases the hold on lock. The
 171    ///     next Lock caller waiting for the lock will then be woken up and given
 172    ///     ownership of the lock.
 173    /// </summary>
 174    /// <param name="request">The request to send to the server</param>
 175    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 176    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 177    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 178    /// <returns>The response received from the server.</returns>
 179    public UnlockResponse Unlock(UnlockRequest request, Metadata headers = null,
 10180        DateTime? deadline = null, CancellationToken cancellationToken = default) => CallEtcd(connection => connection
 10181        .LockClient
 10182        .Unlock(request, headers, deadline, cancellationToken));
 183
 184    /// <summary>
 185    ///     UnlockAsync takes a key returned by Lock and releases the hold on lock. The
 186    ///     next Lock caller waiting for the lock will then be woken up and given
 187    ///     ownership of the lock.
 188    /// </summary>
 189    /// <param name="key">the lock ownership key granted by Lock.</param>
 190    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 191    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 192    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 193    /// <returns>The response received from the server.</returns>
 194    public async Task<UnlockResponse> UnlockAsync(string key, Metadata headers = null,
 195        DateTime? deadline = null, CancellationToken cancellationToken = default) =>
 2196        await UnlockAsync(new UnlockRequest { Key = ByteString.CopyFromUtf8(key) }, headers, deadline,
 2197            cancellationToken).ConfigureAwait(false);
 198
 199    /// <summary>
 200    ///     UnlockAsync takes a key returned by Lock and releases the hold on lock. The
 201    ///     next Lock caller waiting for the lock will then be woken up and given
 202    ///     ownership of the lock.
 203    /// </summary>
 204    /// <param name="request">The request to send to the server</param>
 205    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 206    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 207    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 208    /// <returns>The response received from the server.</returns>
 209    public async Task<UnlockResponse> UnlockAsync(UnlockRequest request, Metadata headers = null,
 11210        DateTime? deadline = null, CancellationToken cancellationToken = default) => await CallEtcdAsync(
 22211        async connection => await connection.LockClient
 22212            .UnlockAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 213}

/home/runner/work/dotnet-etcd/dotnet-etcd/dotnet-etcd/maintenanceClient.cs

#LineLine coverage
 1using System;
 2using System.Threading;
 3using System.Threading.Tasks;
 4using Etcdserverpb;
 5using Grpc.Core;
 6
 7namespace dotnet_etcd;
 8
 9public partial class EtcdClient
 10{
 11    /// <summary>
 12    ///     Alarm activates, deactivates, and queries alarms regarding cluster health
 13    /// </summary>
 14    /// <param name="request">Alarm request</param>
 15    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 16    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 17    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 18    /// <returns>Alarm Response</returns>
 19    public AlarmResponse Alarm(AlarmRequest request, Metadata headers = null, DateTime? deadline = null,
 620        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.MaintenanceClient
 621        .Alarm(request, headers, deadline, cancellationToken));
 22
 23    /// <summary>
 24    ///     Alarm activates, deactivates, and queries alarms regarding cluster health in async
 25    /// </summary>
 26    /// <param name="request">Alarm request</param>
 27    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 28    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 29    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 30    /// <returns>Alarm Response</returns>
 31    public async Task<AlarmResponse> AlarmAsync(AlarmRequest request, Metadata headers = null,
 32        DateTime? deadline = null,
 633        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 634        .MaintenanceClient
 635        .AlarmAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 36
 37    /// <summary>
 38    ///     Status gets the status of the member.
 39    /// </summary>
 40    /// <param name="request">Status Request</param>
 41    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 42    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 43    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 44    /// <returns>Status response</returns>
 45    public StatusResponse Status(StatusRequest request, Metadata headers = null,
 46        DateTime? deadline = null,
 1847        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.MaintenanceClient
 1848        .Status(request, headers, deadline, cancellationToken));
 49
 50    /// <summary>
 51    ///     Status gets the status of the member in async.
 52    /// </summary>
 53    /// <param name="request">Status Request</param>
 54    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 55    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 56    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 57    /// <returns>Status response</returns>
 58    public async Task<StatusResponse> StatusAsync(StatusRequest request, Metadata headers = null,
 59        DateTime? deadline = null,
 1660        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 1661        .MaintenanceClient
 1662        .StatusAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 63
 64    /// <summary>
 65    ///     Defragment defragments a member's backend database to recover storage space.
 66    /// </summary>
 67    /// <param name="request">Defragment Request</param>
 68    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 69    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 70    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 71    /// <returns>Defragment Response</returns>
 72    public DefragmentResponse Defragment(DefragmentRequest request, Metadata headers = null,
 73        DateTime? deadline = null,
 674        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.MaintenanceClient
 675        .Defragment(request, headers, deadline, cancellationToken));
 76
 77    /// <summary>
 78    ///     Defragment defragments a member's backend database to recover storage space in async.
 79    /// </summary>
 80    /// <param name="request">Defragment Request</param>
 81    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 82    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 83    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 84    /// <returns>Defragment Response</returns>
 85    public async Task<DefragmentResponse> DefragmentAsync(DefragmentRequest request,
 86        Metadata headers = null, DateTime? deadline = null,
 687        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 688        .MaintenanceClient
 689        .DefragmentAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 90
 91    /// <summary>
 92    ///     Hash computes the hash of whole backend keyspace,
 93    ///     including key, lease, and other buckets in storage.
 94    ///     This is designed for testing ONLY!
 95    ///     Do not rely on this in production with ongoing transactions,
 96    ///     since Hash operation does not hold MVCC locks.
 97    ///     Use "HashKV" API instead for "key" bucket consistency checks.
 98    /// </summary>
 99    /// <param name="request">Hash Request</param>
 100    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 101    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 102    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 103    /// <returns>Hash Response</returns>
 104    public HashResponse Hash(HashRequest request, Metadata headers = null, DateTime? deadline = null,
 6105        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.MaintenanceClient
 6106        .Hash(request, headers, deadline, cancellationToken));
 107
 108    /// <summary>
 109    ///     Hash computes the hash of whole backend keyspace,
 110    ///     including key, lease, and other buckets in storage in async.
 111    ///     This is designed for testing ONLY!
 112    ///     Do not rely on this in production with ongoing transactions,
 113    ///     since Hash operation does not hold MVCC locks.
 114    ///     Use "HashKV" API instead for "key" bucket consistency checks.
 115    /// </summary>
 116    /// <param name="request">Hash Request</param>
 117    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 118    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 119    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 120    /// <returns>Hash Response</returns>
 121    public async Task<HashResponse> HashAsync(HashRequest request, Metadata headers = null,
 122        DateTime? deadline = null,
 6123        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 6124        .MaintenanceClient
 6125        .HashAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 126
 127    /// <summary>
 128    ///     HashKV computes the hash of all MVCC keys up to a given revision.
 129    ///     It only iterates "key" bucket in backend storage.
 130    /// </summary>
 131    /// <param name="request">HashKV Request</param>
 132    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 133    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 134    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 135    /// <returns>HashKV Response</returns>
 136    public HashKVResponse HashKV(HashKVRequest request, Metadata headers = null,
 137        DateTime? deadline = null,
 8138        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.MaintenanceClient
 8139        .HashKV(request, headers, deadline, cancellationToken));
 140
 141    /// <summary>
 142    ///     HashKV computes the hash of all MVCC keys up to a given revision in async.
 143    ///     It only iterates "key" bucket in backend storage.
 144    /// </summary>
 145    /// <param name="request">HashKV Request</param>
 146    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 147    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 148    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 149    /// <returns>HashKV Response</returns>
 150    public async Task<HashKVResponse> HashKVAsync(HashKVRequest request, Metadata headers = null,
 151        DateTime? deadline = null,
 8152        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 8153        .MaintenanceClient
 8154        .HashKVAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 155
 156    /// <summary>
 157    ///     Snapshot sends a snapshot of the entire backend from a member over a stream to a client.
 158    /// </summary>
 159    /// <param name="request">The request to send to the server.</param>
 160    /// <param name="method"></param>
 161    /// <param name="cancellationToken"></param>
 162    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 163    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 164    public async Task Snapshot(SnapshotRequest request, Action<SnapshotResponse> method,
 1165        CancellationToken cancellationToken, Metadata headers = null, DateTime? deadline = null) => await CallEtcdAsync(
 1166        async connection =>
 1167        {
 1168            using (AsyncServerStreamingCall<SnapshotResponse> snapshotter = connection
 1169                       .MaintenanceClient.Snapshot(request, headers, deadline, cancellationToken))
 1170            {
 3171                while (await snapshotter.ResponseStream.MoveNext(cancellationToken).ConfigureAwait(false))
 2172                {
 2173                    SnapshotResponse update = snapshotter.ResponseStream.Current;
 2174                    method(update);
 2175                }
 1176            }
 2177        }).ConfigureAwait(false);
 178
 179    /// <summary>
 180    ///     Snapshot sends a snapshot of the entire backend from a member over a stream to a client.
 181    /// </summary>
 182    /// <param name="request">The request to send to the server.</param>
 183    /// <param name="methods"></param>
 184    /// <param name="cancellationToken"></param>
 185    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 186    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 187    public async Task Snapshot(SnapshotRequest request, Action<SnapshotResponse>[] methods,
 1188        CancellationToken cancellationToken, Metadata headers = null, DateTime? deadline = null) => await CallEtcdAsync(
 1189        async connection =>
 1190        {
 1191            using (AsyncServerStreamingCall<SnapshotResponse> snapshotter = connection
 1192                       .MaintenanceClient.Snapshot(request, headers, deadline, cancellationToken))
 1193            {
 2194                while (await snapshotter.ResponseStream.MoveNext(cancellationToken).ConfigureAwait(false))
 1195                {
 1196                    SnapshotResponse update = snapshotter.ResponseStream.Current;
 7197                    foreach (Action<SnapshotResponse> method in methods)
 2198                    {
 2199                        method(update);
 2200                    }
 1201                }
 1202            }
 2203        }).ConfigureAwait(false);
 204
 205    /// <summary>
 206    ///     MoveLeader requests current leader node to transfer its leadership to transferee.
 207    /// </summary>
 208    /// <param name="request">MoveLeader Request</param>
 209    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 210    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 211    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 212    /// <returns>MoveLeader Response</returns>
 213    public MoveLeaderResponse MoveLeader(MoveLeaderRequest request, Metadata headers = null,
 214        DateTime? deadline = null,
 2215        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.MaintenanceClient
 2216        .MoveLeader(request, headers, deadline, cancellationToken));
 217
 218    /// <summary>
 219    ///     MoveLeader requests current leader node to transfer its leadership to transferee in async.
 220    /// </summary>
 221    /// <param name="request">MoveLeader Request</param>
 222    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 223    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 224    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 225    /// <returns>MoveLeader Response</returns>
 226    public async Task<MoveLeaderResponse> MoveLeaderAsync(MoveLeaderRequest request,
 227        Metadata headers = null, DateTime? deadline = null,
 2228        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 2229        .MaintenanceClient
 2230        .MoveLeaderAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 231
 232    /// <summary>
 233    ///     Downgrade validates, enables or cancels a cluster downgrade to a lower minor version (see <see cref="Downgra
 234    /// </summary>
 235    /// <param name="request">The request to send to the server.</param>
 236    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 237    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 238    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 239    /// <returns>The response received from the server.</returns>
 240    public DowngradeResponse Downgrade(DowngradeRequest request, Metadata headers = null, DateTime? deadline = null,
 4241        CancellationToken cancellationToken = default) => CallEtcd(connection => connection.MaintenanceClient
 4242        .Downgrade(request, headers, deadline, cancellationToken));
 243
 244    /// <summary>
 245    ///     Downgrade validates, enables or cancels a cluster downgrade to a lower minor version in async (see <see cref
 246    /// </summary>
 247    /// <param name="request">The request to send to the server.</param>
 248    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 249    /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 250    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 251    /// <returns>The response received from the server.</returns>
 252    public async Task<DowngradeResponse> DowngradeAsync(DowngradeRequest request, Metadata headers = null,
 253        DateTime? deadline = null,
 4254        CancellationToken cancellationToken = default) => await CallEtcdAsync(async connection => await connection
 4255        .MaintenanceClient
 4256        .DowngradeAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false);
 257}

/home/runner/work/dotnet-etcd/dotnet-etcd/dotnet-etcd/Util.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Text;
 4using System.Threading.Tasks;
 5using dotnet_etcd.interfaces;
 6using dotnet_etcd.multiplexer;
 7using Etcdserverpb;
 8using Google.Protobuf;
 9using Grpc.Core;
 10using Mvccpb;
 11
 12namespace dotnet_etcd;
 13
 14public partial class EtcdClient
 15{
 16    /// <summary>
 17    ///     Converts RangeResponse to Dictionary
 18    /// </summary>
 19    /// <returns>IDictionary corresponding the RangeResponse</returns>
 20    /// <param name="resp">RangeResponse received from etcd server</param>
 21    private static Dictionary<string, string> RangeRespondToDictionary(RangeResponse resp)
 322    {
 323        Dictionary<string, string> resDictionary = new();
 2124        foreach (KeyValue kv in resp.Kvs)
 625        {
 626            resDictionary.Add(kv.Key.ToStringUtf8(), kv.Value.ToStringUtf8());
 627        }
 28
 329        return resDictionary;
 330    }
 31
 32    /// <summary>
 33    ///     Gets the range end for a prefix: the smallest key greater than every key that starts with
 34    ///     <paramref name="prefix" />, computed on the raw bytes exactly as etcd's own client does
 35    ///     (increment the last byte below 0xFF and truncate after it). An empty prefix, or one made
 36    ///     only of 0xFF bytes, has no upper bound and yields <c>"\0"</c>, which etcd reads as
 37    ///     "to the end of the key space".
 38    /// </summary>
 39    /// <param name="prefix">The prefix, as the exact bytes that will be sent as the range key.</param>
 40    /// <returns>The range end to send alongside <paramref name="prefix" />.</returns>
 41    public static ByteString GetRangeEnd(ByteString prefix)
 8642    {
 8643        ArgumentNullException.ThrowIfNull(prefix);
 44
 8545        byte[] end = prefix.ToByteArray();
 17846        for (int i = end.Length - 1; i >= 0; i--)
 8547        {
 8548            if (end[i] < 0xff)
 8149            {
 8150                end[i]++;
 8151                return ByteString.CopyFrom(end, 0, i + 1);
 52            }
 453        }
 54
 455        return ByteString.CopyFrom(0);
 8556    }
 57
 58    /// <summary>
 59    ///     String form of <see cref="GetRangeEnd(ByteString)" />. The range end is computed on the
 60    ///     prefix's UTF-8 bytes and returned as a string when those bytes are themselves valid UTF-8,
 61    ///     which is always the case for ASCII prefixes. When they are not (a prefix ending in
 62    ///     <c>ÿ</c>, for instance, has the range end bytes <c>C3 C0</c>) no string can carry the
 63    ///     result and an <see cref="ArgumentException" /> is thrown: build the request with the
 64    ///     <see cref="ByteString" /> overload instead. The prefix-based Get/Delete/Watch methods on
 65    ///     this client already do.
 66    /// </summary>
 67    /// <param name="prefixKey">Prefix key</param>
 68    /// <returns>The range end for prefix</returns>
 69    public static string GetRangeEnd(string prefixKey)
 2270    {
 2271        ArgumentNullException.ThrowIfNull(prefixKey);
 72
 2173        ByteString end = GetRangeEnd(ByteString.CopyFromUtf8(prefixKey));
 74        try
 2175        {
 2176            return new UTF8Encoding(false, true).GetString(end.Span);
 77        }
 278        catch (DecoderFallbackException ex)
 279        {
 280            throw new ArgumentException(
 281                $"The range end for prefix \"{prefixKey}\" is not valid UTF-8 and cannot be returned as a " +
 282                "string; use GetRangeEnd(ByteString) and set RangeEnd on the request directly.",
 283                nameof(prefixKey), ex);
 84        }
 1985    }
 86
 87    /// <summary>
 88    ///     Converts a key to the bytes sent in a range request. An empty key becomes <c>"\0"</c>,
 89    ///     which etcd treats as the start of the key space (used for "all keys" ranges).
 90    /// </summary>
 91    /// <param name="key">The key or prefix.</param>
 92    /// <returns>The key bytes to put on the request.</returns>
 93    public static ByteString GetStringByteForRangeRequests(string key) =>
 2594        key.Length == 0 ? ByteString.CopyFrom(0) : ByteString.CopyFromUtf8(key);
 95
 96    /// <summary>
 97    ///     Runs <paramref name="etcdCallFunc" /> against this client's <see cref="IConnection" />.
 98    ///     Retries for transient failures are configured on the gRPC channel, not here.
 99    /// </summary>
 100    /// <typeparam name="TResponse">The type of the response that is returned from the call to etcd</typeparam>
 101    /// <param name="etcdCallFunc">The call to make with the connection's gRPC clients.</param>
 102    /// <returns>Whatever <paramref name="etcdCallFunc" /> returns.</returns>
 191103    private TResponse CallEtcd<TResponse>(Func<IConnection, TResponse> etcdCallFunc) => etcdCallFunc(_connection);
 104
 105    /// <summary>
 106    ///     Runs <paramref name="etcdCallFunc" /> against this client's <see cref="IConnection" />.
 107    ///     Retries for transient failures are configured on the gRPC channel, not here.
 108    /// </summary>
 109    /// <typeparam name="TResponse">The type of the response that is returned from the call to etcd</typeparam>
 110    /// <param name="etcdCallFunc">The call to make with the connection's gRPC clients.</param>
 111    /// <returns>Whatever <paramref name="etcdCallFunc" /> returns.</returns>
 112    private Task<TResponse> CallEtcdAsync<TResponse>(Func<IConnection, Task<TResponse>> etcdCallFunc) =>
 591113        etcdCallFunc(_connection);
 114
 115    /// <summary>
 116    ///     Runs <paramref name="etcdCallFunc" /> against this client's <see cref="IConnection" />.
 117    ///     Retries for transient failures are configured on the gRPC channel, not here.
 118    /// </summary>
 119    /// <param name="etcdCallFunc">The call to make with the connection's gRPC clients.</param>
 120    /// <returns>Whatever <paramref name="etcdCallFunc" /> returns.</returns>
 23121    private Task CallEtcdAsync(Func<IConnection, Task> etcdCallFunc) => etcdCallFunc(_connection);
 122}

/home/runner/work/dotnet-etcd/dotnet-etcd/dotnet-etcd/watchclient/watchClient.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Threading;
 5using System.Threading.Tasks;
 6using Etcdserverpb;
 7using Google.Protobuf;
 8using Grpc.Core;
 9
 10namespace dotnet_etcd;
 11
 12public partial class EtcdClient
 13{
 14    /// <summary>
 15    ///     Pairs watch requests with callbacks. Three shapes are accepted: one callback per request
 16    ///     (paired by index), a single callback shared by every request, or every callback attached
 17    ///     to a single request. The last two are what the key-based overloads produce, e.g.
 18    ///     <c>Watch(key, methods)</c> and <c>Watch(keys, method)</c>, which used to be rejected here.
 19    /// </summary>
 20    private static Action<T>[] PairCallbacks<T>(int requestCount, Action<T>[] methods)
 3121    {
 3122        ArgumentNullException.ThrowIfNull(methods);
 23
 3124        if (methods.Length == requestCount)
 2125        {
 2126            return methods;
 27        }
 28
 1029        if (methods.Length == 1)
 430        {
 431            return Enumerable.Repeat(methods[0], requestCount).ToArray();
 32        }
 33
 634        if (requestCount == 1)
 435        {
 436            Action<T>[] all = methods;
 437            return [value =>
 838            {
 5639                foreach (Action<T> method in all)
 1640                {
 1641                    method(value);
 1642                }
 1243            }];
 44        }
 45
 246        throw new ArgumentException(
 247            $"Expected one callback per request ({requestCount}), a single callback for all requests, " +
 248            $"or all callbacks for a single request; got {methods.Length} callbacks.", nameof(methods));
 2949    }
 50
 51    /// <summary>
 52    ///     Watches the specified requests and passes the watch events to the methods provided asynchronously.
 53    /// </summary>
 54    /// <param name="requests">Watch Requests containing keys to be watched</param>
 55    /// <param name="methods">Methods to which watch events should be passed on</param>
 56    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 57    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 58    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 59    /// <returns>A task that completes with an array of watch IDs</returns>
 60    public async Task<long[]> WatchAsync(WatchRequest[] requests, Action<WatchEvent[]>[] methods,
 61        Metadata headers = null,
 62        DateTime? deadline = null,
 63        CancellationToken cancellationToken = default)
 664    {
 665        methods = PairCallbacks(requests.Length, methods);
 66
 567        long[] watchIds = new long[requests.Length];
 68
 2669        for (int i = 0; i < requests.Length; i++)
 870        {
 71            // Capture the loop index per iteration; otherwise the closure below would read the
 72            // shared loop variable (== requests.Length when an event later arrives) and throw
 73            // IndexOutOfRangeException, silently dropping every event.
 874            int index = i;
 75
 76            // Create a wrapper that converts WatchResponse to WatchEvent[]
 877            Action<WatchResponse> wrapper = response =>
 1378            {
 1879                WatchEvent[] events = response.Events.Select(e => new WatchEvent
 1880                {
 1881                    Key = e.Kv.Key.ToStringUtf8(), Value = e.Kv.Value.ToStringUtf8(), Type = e.Type
 1882                }).ToArray();
 883
 1384                methods[index](events);
 2185            };
 86
 887            watchIds[i] = await _watchManager.WatchAsync(requests[i], wrapper, headers, deadline, cancellationToken)
 888                .ConfigureAwait(false);
 889        }
 90
 591        return watchIds;
 592    }
 93
 94    /// <summary>
 95    ///     Watches the specified requests and passes the watch events of every one of them to the same method.
 96    /// </summary>
 97    /// <param name="requests">Watch Requests containing keys to be watched</param>
 98    /// <param name="method">Method to which watch events should be passed on</param>
 99    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 100    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 101    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 102    /// <returns>A task that completes with an array of watch IDs, in request order</returns>
 103    public Task<long[]> WatchAsync(WatchRequest[] requests, Action<WatchEvent[]> method, Metadata headers = null,
 104        DateTime? deadline = null, CancellationToken cancellationToken = default)
 1105    {
 1106        List<Task<long>> tasks = [];
 107
 7108        foreach (WatchRequest request in requests)
 2109        {
 110            // Create a wrapper that converts WatchResponse to WatchEvent[]
 2111            Action<WatchResponse> wrapper = response =>
 4112            {
 6113                WatchEvent[] events = response.Events.Select(e => new WatchEvent
 6114                {
 6115                    Key = e.Kv.Key.ToStringUtf8(), Value = e.Kv.Value.ToStringUtf8(), Type = e.Type
 6116                }).ToArray();
 2117
 4118                method(events);
 6119            };
 120
 2121            tasks.Add(_watchManager.WatchAsync(request, wrapper, headers, deadline, cancellationToken));
 2122        }
 123
 1124        return Task.WhenAll(tasks);
 1125    }
 126    // CancelWatch methods are already defined in EtcdClient.cs
 127
 128    /// <summary>
 129    ///     Watches the specified requests and passes the watch response to the methods provided.
 130    /// </summary>
 131    /// <param name="requests">Watch Requests containing keys to be watched</param>
 132    /// <param name="methods">Methods to which a watch response should be passed on</param>
 133    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 134    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 135    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 136    public void Watch(WatchRequest[] requests, Action<WatchResponse>[] methods, Metadata headers = null,
 137        DateTime? deadline = null,
 138        CancellationToken cancellationToken = default)
 16139    {
 16140        methods = PairCallbacks(requests.Length, methods);
 141
 64142        for (int i = 0; i < requests.Length; i++)
 17143        {
 17144            _watchManager.Watch(requests[i], methods[i], headers, deadline, cancellationToken);
 17145        }
 15146    }
 147
 148    /// <summary>
 149    ///     Watches the specified requests and passes the watch events to the methods provided.
 150    /// </summary>
 151    /// <param name="requests">Watch Requests containing keys to be watched</param>
 152    /// <param name="methods">Methods to which watch events should be passed on</param>
 153    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 154    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 155    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 156    public void Watch(WatchRequest[] requests, Action<WatchEvent[]>[] methods, Metadata headers = null,
 157        DateTime? deadline = null,
 158        CancellationToken cancellationToken = default)
 5159    {
 5160        methods = PairCallbacks(requests.Length, methods);
 161
 26162        for (int i = 0; i < requests.Length; i++)
 8163        {
 164            // Capture the loop index per iteration; otherwise the closure below would read the
 165            // shared loop variable (== requests.Length when an event later arrives) and throw
 166            // IndexOutOfRangeException, silently dropping every event.
 8167            int index = i;
 168
 169            // Create a wrapper that converts WatchResponse to WatchEvent[]
 8170            Action<WatchResponse> wrapper = response =>
 13171            {
 18172                WatchEvent[] events = [.. response.Events.Select(e => new WatchEvent
 18173                {
 18174                    Key = e.Kv.Key.ToStringUtf8(), Value = e.Kv.Value.ToStringUtf8(), Type = e.Type
 18175                })];
 8176
 13177                methods[index](events);
 21178            };
 179
 8180            _watchManager.Watch(requests[i], wrapper, headers, deadline, cancellationToken);
 8181        }
 5182    }
 183
 184    #region Watch Key
 185
 186    /// <summary>
 187    ///     Watches a key according to the specified watch request and
 188    ///     passes the watch response to the method provided.
 189    /// </summary>
 190    /// <param name="request">Watch Request containing a key to be watched</param>
 191    /// <param name="method">Method to which a watch response should be passed on</param>
 192    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 193    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 194    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 195    /// <returns>A task that completes with the watch ID</returns>
 196    public Task<long> WatchAsync(WatchRequest request, Action<WatchResponse> method, Metadata headers = null,
 197        DateTime? deadline = null,
 198        CancellationToken cancellationToken = default) =>
 1199        _watchManager.WatchAsync(request, method, headers, deadline, cancellationToken);
 200
 201    /// <summary>
 202    ///     Watches a key according to the specified watch request and
 203    ///     passes the watch response to the methods provided.
 204    /// </summary>
 205    /// <param name="request">Watch Request containing a key to be watched</param>
 206    /// <param name="methods">Methods to which a watch response should be passed on</param>
 207    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 208    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 209    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 210    /// <returns>A task that completes with the watch ID</returns>
 211    public Task<long> WatchAsync(WatchRequest request, Action<WatchResponse>[] methods, Metadata headers = null,
 212        DateTime? deadline = null,
 213        CancellationToken cancellationToken = default)
 1214    {
 215        // Create a wrapper method that calls all the methods
 1216        Action<WatchResponse> wrapper = response =>
 2217        {
 14218            foreach (Action<WatchResponse> method in methods)
 4219            {
 4220                method(response);
 4221            }
 3222        };
 223
 1224        return _watchManager.WatchAsync(request, wrapper, headers, deadline, cancellationToken);
 1225    }
 226
 227    /// <summary>
 228    ///     Watches a key according to the specified watch requests and
 229    ///     passes the watch response to the method provided.
 230    /// </summary>
 231    /// <param name="requests">Watch Requests containing keys to be watched</param>
 232    /// <param name="method">Method to which a watch response should be passed on</param>
 233    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 234    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 235    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 236    /// <returns>A task that completes with an array of watch IDs</returns>
 237    public async Task<long[]> WatchAsync(WatchRequest[] requests, Action<WatchResponse> method, Metadata headers = null,
 238        DateTime? deadline = null,
 239        CancellationToken cancellationToken = default)
 1240    {
 1241        long[] watchIds = new long[requests.Length];
 242
 6243        for (int i = 0; i < requests.Length; i++)
 2244        {
 2245            watchIds[i] = await _watchManager.WatchAsync(requests[i], method, headers, deadline, cancellationToken)
 2246                .ConfigureAwait(false);
 2247        }
 248
 1249        return watchIds;
 1250    }
 251
 252    /// <summary>
 253    ///     Watches a key according to the specified watch requests and
 254    ///     passes the watch response to the methods provided.
 255    /// </summary>
 256    /// <param name="requests">Watch Requests containing keys to be watched</param>
 257    /// <param name="methods">Methods to which a watch response should be passed on</param>
 258    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 259    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 260    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 261    /// <returns>A task that completes with an array of watch IDs</returns>
 262    public async Task<long[]> WatchAsync(WatchRequest[] requests, Action<WatchResponse>[] methods,
 263        Metadata headers = null,
 264        DateTime? deadline = null,
 265        CancellationToken cancellationToken = default)
 4266    {
 4267        methods = PairCallbacks(requests.Length, methods);
 268
 4269        long[] watchIds = new long[requests.Length];
 270
 20271        for (int i = 0; i < requests.Length; i++)
 6272        {
 6273            watchIds[i] = await _watchManager.WatchAsync(requests[i], methods[i], headers, deadline, cancellationToken)
 6274                .ConfigureAwait(false);
 6275        }
 276
 4277        return watchIds;
 4278    }
 279
 280    /// <summary>
 281    ///     Watches a key according to the specified watch request and
 282    ///     passes the minimal watch event data to the method provided.
 283    /// </summary>
 284    /// <param name="request">Watch Request containing a key to be watched</param>
 285    /// <param name="method">Method to which minimal watch events data should be passed on</param>
 286    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 287    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 288    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 289    public Task WatchAsync(WatchRequest request, Action<WatchEvent[]> method, Metadata headers = null,
 290        DateTime? deadline = null,
 291        CancellationToken cancellationToken = default)
 1292    {
 293        // Create a wrapper that converts WatchResponse to WatchEvent[]
 1294        Action<WatchResponse> wrapper = response =>
 2295        {
 2296            WatchEvent[] events = response.Events.Select(i =>
 1297            {
 1298                return new WatchEvent
 1299                {
 1300                    Key = i.Kv.Key.ToStringUtf8(), Value = i.Kv.Value.ToStringUtf8(), Type = i.Type
 1301                };
 3302            }).ToArray();
 1303
 2304            method(events);
 3305        };
 306
 1307        return _watchManager.WatchAsync(request, wrapper, headers, deadline, cancellationToken);
 1308    }
 309
 310    /// <summary>
 311    ///     Watches a key according to the specified watch request and
 312    ///     passes the minimal watch event data to the methods provided.
 313    /// </summary>
 314    /// <param name="request">Watch Request containing a key to be watched</param>
 315    /// <param name="methods">Methods to which minimal watch events data should be passed on</param>
 316    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 317    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 318    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 319    public Task WatchAsync(WatchRequest request, Action<WatchEvent[]>[] methods, Metadata headers = null,
 320        DateTime? deadline = null,
 321        CancellationToken cancellationToken = default)
 1322    {
 323        // Create a wrapper that converts WatchResponse to WatchEvent[] and calls all methods
 1324        Action<WatchResponse> wrapper = response =>
 2325        {
 2326            WatchEvent[] events = response.Events.Select(i =>
 1327            {
 1328                return new WatchEvent
 1329                {
 1330                    Key = i.Kv.Key.ToStringUtf8(), Value = i.Kv.Value.ToStringUtf8(), Type = i.Type
 1331                };
 3332            }).ToArray();
 1333
 14334            foreach (Action<WatchEvent[]> method in methods)
 4335            {
 4336                method(events);
 4337            }
 3338        };
 339
 1340        return _watchManager.WatchAsync(request, wrapper, headers, deadline, cancellationToken);
 1341    }
 342
 343    /// <summary>
 344    ///     Watches the specified key and passes the watch response to the method provided.
 345    /// </summary>
 346    /// <param name="request">Watch Request</param>
 347    /// <param name="method">Method to which a watch response should be passed on</param>
 348    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 349    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 350    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 351    public void Watch(WatchRequest request, Action<WatchResponse> method, Metadata headers = null,
 352        DateTime? deadline = null,
 353        CancellationToken cancellationToken = default) =>
 1354        _watchManager.Watch(request, method, headers, deadline, cancellationToken);
 355
 356    /// <summary>
 357    ///     Watches a key according to the specified watch request and
 358    ///     passes the watch response to the methods provided.
 359    /// </summary>
 360    /// <param name="request">Watch Request containing a key to be watched</param>
 361    /// <param name="methods">Methods to which a watch response should be passed on</param>
 362    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 363    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 364    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 365    public void Watch(WatchRequest request, Action<WatchResponse>[] methods,
 366        Metadata headers = null, DateTime? deadline = null,
 1367        CancellationToken cancellationToken = default) => Watch([request], methods, headers,
 1368        deadline, cancellationToken);
 369
 370
 371    /// <summary>
 372    ///     Watches the specified keys and passes the watch response to the method provided.
 373    /// </summary>
 374    /// <param name="key">Key to watch</param>
 375    /// <param name="method">Method to which a watch response should be passed on</param>
 376    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 377    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 378    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 379    public void Watch(string key, Action<WatchResponse> method, Metadata headers = null,
 380        DateTime? deadline = null,
 11381        CancellationToken cancellationToken = default) => Watch([key],
 11382        [method], headers, deadline, cancellationToken);
 383
 384    /// <summary>
 385    ///     Watches the specified key and passes the watch response to the methods provided.
 386    /// </summary>
 387    /// <param name="key">Key to be watched</param>
 388    /// <param name="methods">Methods to which a watch response should be passed on</param>
 389    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 390    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 391    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 392    public void Watch(string key, Action<WatchResponse>[] methods, Metadata headers = null,
 393        DateTime? deadline = null,
 394        CancellationToken cancellationToken = default) =>
 1395        Watch([key], methods, headers, deadline, cancellationToken);
 396
 397
 398    /// <summary>
 399    ///     Watches the specified keys and passes the watch response to the method provided.
 400    /// </summary>
 401    /// <param name="keys">Keys to be watched</param>
 402    /// <param name="method">Method to which a watch response should be passed on</param>
 403    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 404    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 405    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 406    public void Watch(string[] keys, Action<WatchResponse> method, Metadata headers = null,
 407        DateTime? deadline = null,
 1408        CancellationToken cancellationToken = default) => Watch(keys, [method], headers,
 1409        deadline, cancellationToken);
 410
 411    /// <summary>
 412    ///     Watches the specified keys and passes the watch response to the method provided.
 413    /// </summary>
 414    /// <param name="keys">Keys to be watched</param>
 415    /// <param name="methods">Methods to which a watch response should be passed on</param>
 416    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 417    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 418    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 419    public void Watch(string[] keys, Action<WatchResponse>[] methods, Metadata headers = null,
 420        DateTime? deadline = null,
 421        CancellationToken cancellationToken = default)
 13422    {
 13423        List<WatchRequest> requests = [];
 424
 67425        foreach (string key in keys)
 14426        {
 14427            WatchRequest request = new()
 14428            {
 14429                CreateRequest = new WatchCreateRequest
 14430                {
 14431                    Key = ByteString.CopyFromUtf8(key), ProgressNotify = true, PrevKv = true
 14432                }
 14433            };
 14434            requests.Add(request);
 14435        }
 436
 13437        Watch(requests.ToArray(), methods, headers, deadline, cancellationToken);
 13438    }
 439
 440
 441    /// <summary>
 442    ///     Watches the specified key and passes the minimal watch events data to the method provided.
 443    /// </summary>
 444    /// <param name="key">Key to be watched</param>
 445    /// <param name="method">Method to which minimal watch events data should be passed on</param>
 446    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 447    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 448    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 449    public void Watch(string key, Action<WatchEvent[]> method, Metadata headers = null,
 450        DateTime? deadline = null,
 1451        CancellationToken cancellationToken = default) => Watch([key],
 1452        [method], headers, deadline, cancellationToken);
 453
 454    /// <summary>
 455    ///     Watches the specified key and passes the minimal watch events data to the methods provided.
 456    /// </summary>
 457    /// <param name="key">Key to be watched</param>
 458    /// <param name="methods">Methods to which minimal watch events data should be passed on</param>
 459    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 460    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 461    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 462    public void Watch(string key, Action<WatchEvent[]>[] methods, Metadata headers = null,
 463        DateTime? deadline = null,
 464        CancellationToken cancellationToken = default) =>
 1465        Watch([key], methods, headers, deadline, cancellationToken);
 466
 467    /// <summary>
 468    ///     Watches the specified keys and passes the minimal watch events data to the method provided.
 469    /// </summary>
 470    /// <param name="keys">Keys to be watched</param>
 471    /// <param name="method">Method to which minimal watch events data should be passed on</param>
 472    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 473    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 474    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 475    public void Watch(string[] keys, Action<WatchEvent[]> method, Metadata headers = null,
 476        DateTime? deadline = null,
 1477        CancellationToken cancellationToken = default) => Watch(keys, [method], headers,
 1478        deadline, cancellationToken);
 479
 480    /// <summary>
 481    ///     Watches the specified keys and passes the minimal watch events data to the method provided.
 482    /// </summary>
 483    /// <param name="keys">Keys to be watched</param>
 484    /// <param name="methods">Methods to which minimal watch events data should be passed on</param>
 485    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 486    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 487    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 488    public void Watch(string[] keys, Action<WatchEvent[]>[] methods, Metadata headers = null,
 489        DateTime? deadline = null,
 490        CancellationToken cancellationToken = default)
 3491    {
 3492        List<WatchRequest> requests = [];
 493
 17494        foreach (string key in keys)
 4495        {
 4496            WatchRequest request = new()
 4497            {
 4498                CreateRequest = new WatchCreateRequest { Key = ByteString.CopyFromUtf8(key) }
 4499            };
 4500            requests.Add(request);
 4501        }
 502
 3503        Watch(requests.ToArray(), methods, headers, deadline, cancellationToken);
 3504    }
 505
 506
 507    /// <summary>
 508    ///     Watches the specified key and passes the watch response to the method provided.
 509    /// </summary>
 510    /// <param name="key">Key to be watched</param>
 511    /// <param name="method">Method to which a watch response should be passed on</param>
 512    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 513    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 514    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 515    public Task WatchAsync(string key, Action<WatchResponse> method, Metadata headers = null,
 516        DateTime? deadline = null,
 1517        CancellationToken cancellationToken = default) => WatchAsync([key],
 1518        [method], headers, deadline, cancellationToken);
 519
 520    /// <summary>
 521    ///     Watches the specified key and passes the watch response to the methods provided.
 522    /// </summary>
 523    /// <param name="key">Key to be watched</param>
 524    /// <param name="methods">Methods to which a watch response should be passed on</param>
 525    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 526    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 527    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 528    public Task WatchAsync(string key, Action<WatchResponse>[] methods, Metadata headers = null,
 529        DateTime? deadline = null,
 530        CancellationToken cancellationToken = default) =>
 1531        WatchAsync([key], methods, headers, deadline, cancellationToken);
 532
 533
 534    /// <summary>
 535    ///     Watches the specified keys and passes the watch response to the method provided.
 536    /// </summary>
 537    /// <param name="keys">Keys to be watched</param>
 538    /// <param name="method">Method to which a watch response should be passed on</param>
 539    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 540    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 541    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 542    public Task WatchAsync(string[] keys, Action<WatchResponse> method, Metadata headers = null,
 543        DateTime? deadline = null,
 1544        CancellationToken cancellationToken = default) => WatchAsync(keys, [method],
 1545        headers, deadline, cancellationToken);
 546
 547    /// <summary>
 548    ///     Watches the specified keys and passes the watch response to the method provided.
 549    /// </summary>
 550    /// <param name="keys">Keys to be watched</param>
 551    /// <param name="methods">Methods to which a watch response should be passed on</param>
 552    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 553    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 554    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 555    public Task WatchAsync(string[] keys, Action<WatchResponse>[] methods, Metadata headers = null,
 556        DateTime? deadline = null,
 557        CancellationToken cancellationToken = default)
 3558    {
 3559        List<WatchRequest> requests = [];
 560
 17561        foreach (string key in keys)
 4562        {
 4563            WatchRequest request = new()
 4564            {
 4565                CreateRequest = new WatchCreateRequest
 4566                {
 4567                    Key = ByteString.CopyFromUtf8(key), ProgressNotify = true, PrevKv = true
 4568                }
 4569            };
 4570            requests.Add(request);
 4571        }
 572
 3573        return WatchAsync(requests.ToArray(), methods, headers, deadline, cancellationToken);
 3574    }
 575
 576    /// <summary>
 577    ///     Watches the specified key and passes the minimal watch events data to the method provided.
 578    /// </summary>
 579    /// <param name="key">Key to be watched</param>
 580    /// <param name="method">Method to which minimal watch events data should be passed on</param>
 581    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 582    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 583    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 584    public Task WatchAsync(string key, Action<WatchEvent[]> method, Metadata headers = null,
 585        DateTime? deadline = null,
 1586        CancellationToken cancellationToken = default) => WatchAsync([key],
 1587        [method], headers, deadline, cancellationToken);
 588
 589    /// <summary>
 590    ///     Watches the specified key and passes the minimal watch events data to the methods provided.
 591    /// </summary>
 592    /// <param name="key">Key to be watched</param>
 593    /// <param name="methods">Methods to which minimal watch events data should be passed on</param>
 594    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 595    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 596    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 597    public Task WatchAsync(string key, Action<WatchEvent[]>[] methods, Metadata headers = null,
 598        DateTime? deadline = null,
 599        CancellationToken cancellationToken = default) =>
 1600        WatchAsync([key], methods, headers, deadline, cancellationToken);
 601
 602    /// <summary>
 603    ///     Watches the specified keys and passes the minimal watch events data to the method provided.
 604    /// </summary>
 605    /// <param name="keys">Keys to be watched</param>
 606    /// <param name="method">Method to which minimal watch events data should be passed on</param>
 607    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 608    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 609    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 610    public Task WatchAsync(string[] keys, Action<WatchEvent[]> method, Metadata headers = null,
 611        DateTime? deadline = null,
 1612        CancellationToken cancellationToken = default) => WatchAsync(keys, [method],
 1613        headers, deadline, cancellationToken);
 614
 615    /// <summary>
 616    ///     Watches the specified keys and passes the minimal watch events data to the method provided.
 617    /// </summary>
 618    /// <param name="keys">Keys to be watched</param>
 619    /// <param name="methods">Methods to which minimal watch events data should be passed on</param>
 620    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 621    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 622    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 623    public Task WatchAsync(string[] keys, Action<WatchEvent[]>[] methods, Metadata headers = null,
 624        DateTime? deadline = null,
 625        CancellationToken cancellationToken = default)
 3626    {
 3627        List<WatchRequest> requests = [];
 628
 17629        foreach (string key in keys)
 4630        {
 4631            WatchRequest request = new()
 4632            {
 4633                CreateRequest = new WatchCreateRequest
 4634                {
 4635                    Key = ByteString.CopyFromUtf8(key), ProgressNotify = true, PrevKv = true
 4636                }
 4637            };
 4638            requests.Add(request);
 4639        }
 640
 3641        return WatchAsync(requests.ToArray(), methods, headers, deadline, cancellationToken);
 3642    }
 643
 644    #endregion
 645
 646    #region Watch Range of keys
 647
 648    /// <summary>
 649    ///     Watches the specified key range and passes the watch response to the method provided.
 650    /// </summary>
 651    /// <param name="path">Path to be watched</param>
 652    /// <param name="method">Method to which a watch response should be passed on</param>
 653    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 654    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 655    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 656    /// <returns>A watch ID that can be used to cancel the watch</returns>
 657    public long WatchRange(string path, Action<WatchResponse> method, Metadata headers = null,
 658        DateTime? deadline = null,
 659        CancellationToken cancellationToken = default)
 7660    {
 7661        WatchRequest request = new()
 7662        {
 7663            CreateRequest = new WatchCreateRequest
 7664            {
 7665                Key = GetStringByteForRangeRequests(path),
 7666                RangeEnd = ByteString.CopyFromUtf8(GetRangeEnd(path)),
 7667                ProgressNotify = true,
 7668                PrevKv = true
 7669            }
 7670        };
 671
 7672        return _watchManager.Watch(request, method, headers, deadline, cancellationToken);
 7673    }
 674
 675    /// <summary>
 676    ///     Watches the specified key range and passes the watch response to the methods provided.
 677    /// </summary>
 678    /// <param name="path">Path to be watched</param>
 679    /// <param name="methods">Methods to which a watch response should be passed on</param>
 680    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 681    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 682    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 683    /// <returns>A watch ID that can be used to cancel the watch</returns>
 684    public long WatchRange(string path, Action<WatchResponse>[] methods, Metadata headers = null,
 685        DateTime? deadline = null,
 686        CancellationToken cancellationToken = default)
 1687    {
 688        // Create a wrapper method that calls all the methods
 1689        Action<WatchResponse> wrapper = response =>
 2690        {
 14691            foreach (Action<WatchResponse> method in methods)
 4692            {
 4693                method(response);
 4694            }
 3695        };
 696
 1697        return WatchRange(path, wrapper, headers, deadline, cancellationToken);
 1698    }
 699
 700    /// <summary>
 701    ///     Watches the specified key range and passes the watch response to the method provided.
 702    /// </summary>
 703    /// <param name="paths">Paths to be watched</param>
 704    /// <param name="method">Method to which a watch response should be passed on</param>
 705    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 706    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 707    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 708    /// <returns>An array of watch IDs that can be used to cancel the watches</returns>
 709    public long[] WatchRange(string[] paths, Action<WatchResponse> method, Metadata headers = null,
 710        DateTime? deadline = null,
 711        CancellationToken cancellationToken = default)
 1712    {
 1713        long[] watchIds = new long[paths.Length];
 714
 6715        for (int i = 0; i < paths.Length; i++)
 2716        {
 2717            watchIds[i] = WatchRange(paths[i], method, headers, deadline, cancellationToken);
 2718        }
 719
 1720        return watchIds;
 1721    }
 722
 723    /// <summary>
 724    ///     Watches the specified key range and passes the watch response to the method provided.
 725    /// </summary>
 726    /// <param name="paths">Paths to be watched</param>
 727    /// <param name="methods">Methods to which a watch response should be passed on</param>
 728    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 729    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 730    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 731    /// <returns>An array of watch IDs that can be used to cancel the watches</returns>
 732    public long[] WatchRange(string[] paths, Action<WatchResponse>[] methods, Metadata headers = null,
 733        DateTime? deadline = null,
 734        CancellationToken cancellationToken = default)
 2735    {
 2736        if (paths.Length != methods.Length)
 1737        {
 1738            throw new ArgumentException("The number of paths must match the number of methods");
 739        }
 740
 1741        long[] watchIds = new long[paths.Length];
 742
 6743        for (int i = 0; i < paths.Length; i++)
 2744        {
 2745            watchIds[i] = WatchRange(paths[i], methods[i], headers, deadline, cancellationToken);
 2746        }
 747
 1748        return watchIds;
 1749    }
 750
 751    /// <summary>
 752    ///     Watches the specified key range and passes the watch response to the method provided asynchronously.
 753    /// </summary>
 754    /// <param name="path">Path to be watched</param>
 755    /// <param name="method">Method to which a watch response should be passed on</param>
 756    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 757    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 758    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 759    /// <returns>A task that completes with the watch ID</returns>
 760    public Task<long> WatchRangeAsync(string path, Action<WatchResponse> method, Metadata headers = null,
 761        DateTime? deadline = null,
 762        CancellationToken cancellationToken = default)
 6763    {
 6764        WatchRequest request = new()
 6765        {
 6766            CreateRequest = new WatchCreateRequest
 6767            {
 6768                Key = GetStringByteForRangeRequests(path),
 6769                RangeEnd = ByteString.CopyFromUtf8(GetRangeEnd(path)),
 6770                ProgressNotify = true,
 6771                PrevKv = true
 6772            }
 6773        };
 774
 6775        return _watchManager.WatchAsync(request, method, headers, deadline, cancellationToken);
 6776    }
 777
 778    /// <summary>
 779    ///     Watches the specified key range and passes the watch response to the methods provided asynchronously.
 780    /// </summary>
 781    /// <param name="path">Path to be watched</param>
 782    /// <param name="methods">Methods to which a watch response should be passed on</param>
 783    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 784    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 785    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 786    /// <returns>A task that completes with the watch ID</returns>
 787    public Task<long> WatchRangeAsync(string path, Action<WatchResponse>[] methods, Metadata headers = null,
 788        DateTime? deadline = null,
 789        CancellationToken cancellationToken = default)
 1790    {
 791        // Create a wrapper method that calls all the methods
 1792        Action<WatchResponse> wrapper = response =>
 2793        {
 14794            foreach (Action<WatchResponse> method in methods)
 4795            {
 4796                method(response);
 4797            }
 3798        };
 799
 1800        return WatchRangeAsync(path, wrapper, headers, deadline, cancellationToken);
 1801    }
 802
 803    /// <summary>
 804    ///     Watches the specified key range and passes the watch response to the method provided asynchronously.
 805    /// </summary>
 806    /// <param name="paths">Paths to be watched</param>
 807    /// <param name="method">Method to which a watch response should be passed on</param>
 808    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 809    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 810    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 811    /// <returns>A task that completes with an array of watch IDs</returns>
 812    public async Task<long[]> WatchRangeAsync(string[] paths, Action<WatchResponse> method, Metadata headers = null,
 813        DateTime? deadline = null,
 814        CancellationToken cancellationToken = default)
 1815    {
 1816        long[] watchIds = new long[paths.Length];
 817
 6818        for (int i = 0; i < paths.Length; i++)
 2819        {
 2820            watchIds[i] = await WatchRangeAsync(paths[i], method, headers, deadline, cancellationToken)
 2821                .ConfigureAwait(false);
 2822        }
 823
 1824        return watchIds;
 1825    }
 826
 827    /// <summary>
 828    ///     Watches the specified key range and passes the watch response to the method provided asynchronously.
 829    /// </summary>
 830    /// <param name="paths">Paths to be watched</param>
 831    /// <param name="methods">Methods to which a watch response should be passed on</param>
 832    /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 833    /// <param name="deadline">An optional deadline for the call. The call will be canceled if the deadline is hit.</par
 834    /// <param name="cancellationToken">An optional token for canceling the call.</param>
 835    /// <returns>A task that completes with an array of watch IDs</returns>
 836    public async Task<long[]> WatchRangeAsync(string[] paths, Action<WatchResponse>[] methods, Metadata headers = null,
 837        DateTime? deadline = null,
 838        CancellationToken cancellationToken = default)
 2839    {
 2840        if (paths.Length != methods.Length)
 1841        {
 1842            throw new ArgumentException("The number of paths must match the number of methods");
 843        }
 844
 1845        long[] watchIds = new long[paths.Length];
 846
 6847        for (int i = 0; i < paths.Length; i++)
 2848        {
 2849            watchIds[i] = await WatchRangeAsync(paths[i], methods[i], headers, deadline, cancellationToken)
 2850                .ConfigureAwait(false);
 2851        }
 852
 1853        return watchIds;
 1854    }
 855
 856    #endregion
 857}

Methods/Properties

Authenticate(Etcdserverpb.AuthenticateRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<AuthenticateAsync()
AuthEnable(Etcdserverpb.AuthEnableRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<AuthEnableAsync()
AuthDisable(Etcdserverpb.AuthDisableRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<AuthDisableAsync()
UserAdd(Etcdserverpb.AuthUserAddRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<UserAddAsync()
UserGet(Etcdserverpb.AuthUserGetRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<UserGetAsync()
UserList(Etcdserverpb.AuthUserListRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<UserListAsync()
UserDelete(Etcdserverpb.AuthUserDeleteRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<UserDeleteAsync()
UserChangePassword(Etcdserverpb.AuthUserChangePasswordRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<UserChangePasswordAsync()
UserGrantRole(Etcdserverpb.AuthUserGrantRoleRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<UserGrantRoleAsync()
UserRevokeRole(Etcdserverpb.AuthUserRevokeRoleRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<UserRevokeRoleAsync()
RoleAdd(Etcdserverpb.AuthRoleAddRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<RoleAddAsync()
RoleGet(Etcdserverpb.AuthRoleGetRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<RoleGetAsync()
RoleList(Etcdserverpb.AuthRoleListRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<RoleListAsync()
RoleDelete(Etcdserverpb.AuthRoleDeleteRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<RoleDeleteAsync()
RoleGrantPermission(Etcdserverpb.AuthRoleGrantPermissionRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<RoleGrantPermissionAsync()
RoleRevokePermission(Etcdserverpb.AuthRoleRevokePermissionRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<RoleRevokePermissionAsync()
AuthStatus(Etcdserverpb.AuthStatusRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<AuthStatusAsync()
MemberAdd(Etcdserverpb.MemberAddRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<MemberAddAsync()
MemberRemove(Etcdserverpb.MemberRemoveRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<MemberRemoveAsync()
MemberUpdate(Etcdserverpb.MemberUpdateRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<MemberUpdateAsync()
MemberList(Etcdserverpb.MemberListRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<MemberListAsync()
MemberPromote(Etcdserverpb.MemberPromoteRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<MemberPromoteAsync()
MemberPromote(System.UInt64,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
MemberPromoteAsync()
MemberAddAsLearner(System.String[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
MemberAddAsLearnerAsync()
Campaign(V3Electionpb.CampaignRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Campaign(System.String,System.String,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Campaign(System.String,System.Int64,System.String,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<CampaignAsync()
<CampaignAsync()
CampaignAsync()
Proclaim(V3Electionpb.ProclaimRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Proclaim(V3Electionpb.LeaderKey,System.String,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<ProclaimAsync()
<ProclaimAsync()
Leader(V3Electionpb.LeaderRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Leader(System.String,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<LeaderAsync()
<LeaderAsync()
ObserveAsync()
ObserveAsync()
Resign(V3Electionpb.ResignRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Resign(V3Electionpb.LeaderKey,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<ResignAsync()
<ResignAsync()
Observe(V3Electionpb.LeaderRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Observe(System.String,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
GetConnection()
GetWatchManager()
CancelWatch(System.Int64)
CancelWatch(System.Int64[])
get_Username()
.ctor(Grpc.Core.CallInvoker)
.cctor()
.ctor(System.String,System.Int32,System.String,System.Action`1<Grpc.Net.Client.GrpcChannelOptions>,Grpc.Core.Interceptors.Interceptor[])
.ctor(System.String,System.Action`1<System.Net.Security.SslClientAuthenticationOptions>,System.Int32,System.String,System.Action`1<Grpc.Net.Client.GrpcChannelOptions>,Grpc.Core.Interceptors.Interceptor[])
.ctor(System.String,System.String,System.String,System.Int32,System.String,System.Action`1<Grpc.Net.Client.GrpcChannelOptions>,System.Nullable`1<System.TimeSpan>)
.ctor(dotnet_etcd.interfaces.IConnection,dotnet_etcd.interfaces.IWatchManager)
SetCredentials(System.String,System.String,System.Nullable`1<System.TimeSpan>)
ClearCredentials()
EnsureAuthenticationSupported()
RequestTokenAsync()
Dispose(System.Boolean)
Dispose()
Get(Etcdserverpb.RangeRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Get(System.String,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<GetAsync()
GetAsync()
GetVal(System.String,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
GetValAsync()
GetRange(System.String,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
GetRangeAsync()
GetRangeVal(System.String,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
GetRangeValAsync()
Put(Etcdserverpb.PutRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Put(System.String,System.String,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<PutAsync()
PutAsync()
Delete(Etcdserverpb.DeleteRangeRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Delete(System.String,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<DeleteAsync()
DeleteAsync()
DeleteRange(System.String,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
DeleteRangeAsync()
Transaction(Etcdserverpb.TxnRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<TransactionAsync()
Compact(Etcdserverpb.CompactionRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<CompactAsync()
RangeStream()
<RangeStream()
RangeStreamAsync()
LeaseGrant(Etcdserverpb.LeaseGrantRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<LeaseGrantAsync()
LeaseRevoke(Etcdserverpb.LeaseRevokeRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<LeaseRevokeAsync()
LeaseKeepAlive(System.Threading.CancellationTokenSource,System.Int64,System.Int32,System.Nullable`1<System.Int32>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>)
LeaseKeepAlive()
<LeaseKeepAlive()
LeaseKeepAlive()
<LeaseKeepAlive()
LeaseKeepAlive()
<LeaseKeepAlive()
LeaseKeepAlive()
<LeaseKeepAlive()
LeaseKeepAlive()
<LeaseKeepAlive()
LeaseTimeToLive(Etcdserverpb.LeaseTimeToLiveRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<LeaseTimeToLiveAsync()
LeaseLeases(Etcdserverpb.LeaseLeasesRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<LeaseLeasesAsync()
LeaseLeases(Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
LeaseLeasesAsync()
Lock(System.String,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Lock(System.String,System.Int64,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Lock(V3Lockpb.LockRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
LockAsync()
LockAsync()
LockAsync()
<LockAsync()
Unlock(System.String,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Unlock(V3Lockpb.UnlockRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
UnlockAsync()
UnlockAsync()
<UnlockAsync()
Alarm(Etcdserverpb.AlarmRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<AlarmAsync()
Status(Etcdserverpb.StatusRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<StatusAsync()
Defragment(Etcdserverpb.DefragmentRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<DefragmentAsync()
Hash(Etcdserverpb.HashRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<HashAsync()
HashKV(Etcdserverpb.HashKVRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<HashKVAsync()
Snapshot()
<Snapshot()
Snapshot()
<Snapshot()
MoveLeader(Etcdserverpb.MoveLeaderRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<MoveLeaderAsync()
Downgrade(Etcdserverpb.DowngradeRequest,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
<DowngradeAsync()
RangeRespondToDictionary(Etcdserverpb.RangeResponse)
GetRangeEnd(Google.Protobuf.ByteString)
GetRangeEnd(System.String)
GetStringByteForRangeRequests(System.String)
CallEtcd(System.Func`2<dotnet_etcd.interfaces.IConnection,TResponse>)
CallEtcdAsync(System.Func`2<dotnet_etcd.interfaces.IConnection,System.Threading.Tasks.Task`1<TResponse>>)
CallEtcdAsync(System.Func`2<dotnet_etcd.interfaces.IConnection,System.Threading.Tasks.Task>)
PairCallbacks(System.Int32,System.Action`1<T>[])
WatchAsync()
WatchAsync(Etcdserverpb.WatchRequest[],System.Action`1<dotnet_etcd.WatchEvent[]>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Watch(Etcdserverpb.WatchRequest[],System.Action`1<Etcdserverpb.WatchResponse>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Watch(Etcdserverpb.WatchRequest[],System.Action`1<dotnet_etcd.WatchEvent[]>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchAsync(Etcdserverpb.WatchRequest,System.Action`1<Etcdserverpb.WatchResponse>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchAsync(Etcdserverpb.WatchRequest,System.Action`1<Etcdserverpb.WatchResponse>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchAsync()
WatchAsync()
WatchAsync(Etcdserverpb.WatchRequest,System.Action`1<dotnet_etcd.WatchEvent[]>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchAsync(Etcdserverpb.WatchRequest,System.Action`1<dotnet_etcd.WatchEvent[]>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Watch(Etcdserverpb.WatchRequest,System.Action`1<Etcdserverpb.WatchResponse>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Watch(Etcdserverpb.WatchRequest,System.Action`1<Etcdserverpb.WatchResponse>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Watch(System.String,System.Action`1<Etcdserverpb.WatchResponse>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Watch(System.String,System.Action`1<Etcdserverpb.WatchResponse>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Watch(System.String[],System.Action`1<Etcdserverpb.WatchResponse>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Watch(System.String[],System.Action`1<Etcdserverpb.WatchResponse>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Watch(System.String,System.Action`1<dotnet_etcd.WatchEvent[]>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Watch(System.String,System.Action`1<dotnet_etcd.WatchEvent[]>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Watch(System.String[],System.Action`1<dotnet_etcd.WatchEvent[]>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
Watch(System.String[],System.Action`1<dotnet_etcd.WatchEvent[]>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchAsync(System.String,System.Action`1<Etcdserverpb.WatchResponse>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchAsync(System.String,System.Action`1<Etcdserverpb.WatchResponse>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchAsync(System.String[],System.Action`1<Etcdserverpb.WatchResponse>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchAsync(System.String[],System.Action`1<Etcdserverpb.WatchResponse>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchAsync(System.String,System.Action`1<dotnet_etcd.WatchEvent[]>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchAsync(System.String,System.Action`1<dotnet_etcd.WatchEvent[]>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchAsync(System.String[],System.Action`1<dotnet_etcd.WatchEvent[]>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchAsync(System.String[],System.Action`1<dotnet_etcd.WatchEvent[]>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchRange(System.String,System.Action`1<Etcdserverpb.WatchResponse>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchRange(System.String,System.Action`1<Etcdserverpb.WatchResponse>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchRange(System.String[],System.Action`1<Etcdserverpb.WatchResponse>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchRange(System.String[],System.Action`1<Etcdserverpb.WatchResponse>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchRangeAsync(System.String,System.Action`1<Etcdserverpb.WatchResponse>,Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchRangeAsync(System.String,System.Action`1<Etcdserverpb.WatchResponse>[],Grpc.Core.Metadata,System.Nullable`1<System.DateTime>,System.Threading.CancellationToken)
WatchRangeAsync()
WatchRangeAsync()