/// <summary>
 /// RoleAddAsync adds a new role in async
 /// </summary>
 /// <param name="request">The request to send to the server.</param>
 /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 /// <param name="cancellationToken">An optional token for canceling the call.</param>
 /// <returns>The response received from the server.</returns>
 public async Task <AuthRoleAddResponse> RoleAddAsync(AuthRoleAddRequest request,
                                                      Grpc.Core.Metadata headers          = null, DateTime?deadline = null,
                                                      CancellationToken cancellationToken = default)
 {
     return(await CallEtcdAsync(async (connection) => await connection._authClient
                                .RoleAddAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false));
 }
 /// <summary>
 /// RoleAdd adds a new role
 /// </summary>
 /// <param name="request">The request to send to the server.</param>
 /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 /// <param name="cancellationToken">An optional token for canceling the call.</param>
 /// <returns>The response received from the server.</returns>
 public AuthRoleAddResponse RoleAdd(AuthRoleAddRequest request, Grpc.Core.Metadata headers = null,
                                    DateTime?deadline = null,
                                    CancellationToken cancellationToken = default)
 {
     return(CallEtcd((connection) => connection._authClient
                     .RoleAdd(request, headers, deadline, cancellationToken)));
 }
        /// <summary>
        /// RoleAddAsync adds a new role in async
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <AuthRoleAddResponse> RoleAddAsync(AuthRoleAddRequest request, Metadata headers = null)
        {
            AuthRoleAddResponse response = new AuthRoleAddResponse();
            bool success    = false;
            int  retryCount = 0;

            while (!success)
            {
                try
                {
                    response = await _balancer.GetConnection().authClient.RoleAddAsync(request, headers);

                    success = true;
                }
                catch (RpcException ex) when(ex.StatusCode == StatusCode.Unavailable)
                {
                    retryCount++;
                    if (retryCount >= _balancer._numNodes)
                    {
                        throw ex;
                    }
                }
            }
            return(response);
        }
Exemple #4
0
        /// <summary>
        /// RoleAddAsync adds a new role in async
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <AuthRoleAddResponse> RoleAddAsync(AuthRoleAddRequest request, Metadata headers = null)
        {
            AuthRoleAddResponse response = new AuthRoleAddResponse();

            response = await _balancer.GetConnection().authClient.RoleAddAsync(request, headers);

            return(response);
        }
Exemple #5
0
        /// <summary>
        /// RoleAdd adds a new role
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public AuthRoleAddResponse RoleAdd(AuthRoleAddRequest request, Metadata headers = null)
        {
            AuthRoleAddResponse response = new AuthRoleAddResponse();

            response = _balancer.GetConnection().authClient.RoleAdd(request, headers);

            return(response);
        }
Exemple #6
0
        /// <summary>
        /// RoleAddAsync adds a new role in async
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <AuthRoleAddResponse> RoleAddAsync(AuthRoleAddRequest request)
        {
            AuthRoleAddResponse response = new AuthRoleAddResponse();

            try
            {
                response = await _authClient.RoleAddAsync(request, _headers);
            }
            catch (RpcException ex)
            {
                ResetConnection(ex);
                throw;
            }
            catch
            {
                throw;
            }
            return(response);
        }
Exemple #7
0
        /// <summary>
        /// RoleAdd adds a new role
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public AuthRoleAddResponse RoleAdd(AuthRoleAddRequest request)
        {
            AuthRoleAddResponse response = new AuthRoleAddResponse();

            try
            {
                response = _authClient.RoleAdd(request, _headers);
            }
            catch (RpcException ex)
            {
                ResetConnection(ex);
                throw;
            }
            catch
            {
                throw;
            }
            return(response);
        }