Example #1
0
        /// <summary>
        ///     Creates an <see cref="IEtcdClient" /> for the specified <see cref="Uri" />.
        /// </summary>
        /// <exception cref="ArgumentNullException">Passed <paramref name="uris" /> is null.</exception>
        /// <exception cref="ArgumentException">The <paramref name="uris" /> is not an absolute <see cref="Uri" />.</exception>
        public static IEtcdClient ClientFor(params Uri[] uris)
        {
            if (uris == null)
            {
                throw new ArgumentNullException("uris");
            }

            EndpointPool endpointPool = null;

            try
            {
                endpointPool = EndpointPool.Build()
                               .WithRoutingStrategy(EndpointRoutingStrategy.RoundRobin)
                               .WithVerificationStrategy(EndpointVerificationStrategy.None)
                               .VerifyAndBuild(uris)
                               .Result;
            }
            catch (AggregateException ae)
            {
                ExceptionDispatchInfo.Capture(ae.Flatten().InnerExceptions.First()).Throw();
            }


            return(ClientFor(endpointPool));
        }
Example #2
0
 public WatchRequest(IEtcdClient etcdClient, EndpointPool endpointPool, bool single, params string[] pathParts)
 {
     _etcdClient  = etcdClient;
     EndpointPool = endpointPool;
     PathParts    = pathParts;
     Single       = single;
 }
Example #3
0
 /// <summary>
 ///     Creates an <see cref="IEtcdClient" /> for the specified <see cref="EndpointPool" />.
 /// </summary>
 /// <exception cref="ArgumentNullException">Passed <paramref name="endpointPool" /> is null.</exception>
 public static IEtcdClient ClientFor(EndpointPool endpointPool)
 {
     if (endpointPool == null)
     {
         throw new ArgumentNullException("endpointPool");
     }
     return(new EtcdClient(endpointPool, ClientConfig.Value.DeepCopy()));
 }
Example #4
0
 private Task <HttpResponseMessage> CallEndpoint(bool?recursive, long?index)
 {
     return(EndpointPool.GetEndpointUrl(PathParts)
            .SetQueryParam(Constants.Etcd.Parameter_Wait, Constants.Etcd.Parameter_True)
            .Conditionally(recursive.HasValue && recursive.Value, x => x.SetQueryParam(Constants.Etcd.Parameter_Recursive, Constants.Etcd.Parameter_True))
            // ReSharper disable once PossibleInvalidOperationException
            .Conditionally(index.HasValue, x => x.SetQueryParam(Constants.Etcd.Parameter_WaitIndex, index.Value))
            .WithTimeout(Timeout.InfiniteTimeSpan)
            .GetAsync());
 }
Example #5
0
 public EtcdClient(EndpointPool endpointPool, ClientConfig clientConfig)
 {
     EndpointPool  = endpointPool;
     _clientConfig = clientConfig ?? new ClientConfig();
 }
Example #6
0
 public CompareAndSwapRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts)
 {
 }
Example #7
0
 public DeleteMemberRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts)
 {
 }
 public GetLeaderStatisticsRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts) : base(etcdClient, endpointPool, pathParts)
 {
 }
 protected EndpointPool.Builder CreateSut(EndpointVerificationStrategy strategy = null)
 {
     return(EndpointPool.Build()
            .WithVerificationStrategy(strategy ?? VerificationStrategy));
 }
Example #10
0
 public GetVersionRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts)
 {
 }
Example #11
0
 protected BaseRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
 {
     EtcdClient    = etcdClient;
     _endpointPool = endpointPool;
     _pathParts    = pathParts;
 }
Example #12
0
 public DeleteRequest(IEtcdClient etcdClient, EndpointPool endpointPool, bool isDirectory, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts)
 {
     IsDirectory = isDirectory;
 }
Example #13
0
 public UpsertQueueRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts)
 {
 }
Example #14
0
 public CreateMemberRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts)
 {
     Uris = new List <Uri>();
 }