Exemple #1
0
        public async Task fasfda()
        {
            try
            {
                //docker run --name some-zookeeper --restart always -p 2181:2181 -d zookeeper
                var client = new AlwaysOnZooKeeperClient("localhost:2181");
                client.OnRecconected += () =>
                {
                    "xxx".AddBusinessInfoLog();
                };

                foreach (var i in Com.Range(100))
                {
                    try
                    {
                        await Task.Delay(TimeSpan.FromSeconds(10));
                    }
                    catch (Exception err)
                    {
                        err.AddErrorLog();
                    }
                }

                await Task.Delay(TimeSpan.FromMinutes(10));

                await Task.FromResult(1);
            }
            catch (Exception e)
            {
                //
            }
        }
Exemple #2
0
        public ZKConfigurationProvider(ZKConfigurationOption option, AlwaysOnZooKeeperClient client,
                                       ISerializeProvider serializeProvider = null,
                                       Encoding encoding = null)
        {
            this._option     = option;
            this._client     = client;
            this._serializer = serializeProvider ?? new DefaultSerializeProvider();
            this._encoding   = encoding ?? Encoding.UTF8;

            this._node_watcher = new CallBackWatcher(this.NodeWatchCallback);
        }
Exemple #3
0
        public static IConfigurationBuilder AddZookeeper(
            this IConfigurationBuilder builder,
            AlwaysOnZooKeeperClient client,
            CancellationToken cancellationToken,
            Func <ZKConfigurationOption, ZKConfigurationOption> config = null)
        {
            var option = new ZKConfigurationOption();

            if (config != null)
            {
                option = config.Invoke(option);
            }

            var zkConfigSource = new ZKConfigurationSource(option, client, cancellationToken);

            return(builder.Add(zkConfigSource));
        }
 public ZKConfigurationSource(ZKConfigurationOption option, AlwaysOnZooKeeperClient client, CancellationToken cancellationToken)
 {
     this._provider = new ZKConfigurationProvider(option, client);
 }