Exemple #1
0
        protected override async Task DoSubscribe(ServiceConfig config, Action <IList <ServiceConfig> > onChange)
        {
            var path = $"/dubbo/{config.ServiceName}/providers";

            await CreatePath(path, true);

            var childs = await client.SubscribeChildrenChange(path, ((zk, args) =>
            {
                var configs = args.CurrentChildrens.Select(child =>
                                                           ServiceConfig.ParseServiceUrl(HttpUtility.UrlDecode(child, Encoding.UTF8))).ToArray();
                onChange(configs);
                return(Task.CompletedTask);
            }));

            onChange(childs.Select(child => ServiceConfig.ParseServiceUrl(HttpUtility.UrlDecode(child, Encoding.UTF8)))
                     .ToArray());
            Log.InfoFormat("subscribe {0} success.", path);
        }