Esempio n. 1
0
        public NamingGrpcClientProxy(
            ILogger logger,
            string namespaceId,
            SecurityProxy securityProxy,
            IServerListFactory serverListFactory,
            NacosSdkOptions options,
            ServiceInfoHolder serviceInfoHolder)
        {
            this._logger        = logger;
            this.namespaceId    = namespaceId;
            this.uuid           = Guid.NewGuid().ToString();
            this._options       = options;
            this._securityProxy = securityProxy;

            this.requestTimeout = options.DefaultTimeOut > 0 ? options.DefaultTimeOut : 3000L;

            Dictionary <string, string> labels = new Dictionary <string, string>()
            {
                { RemoteConstants.LABEL_SOURCE, RemoteConstants.LABEL_SOURCE_SDK },
                { RemoteConstants.LABEL_MODULE, RemoteConstants.LABEL_MODULE_NAMING },
            };

            this.rpcClient = RpcClientFactory.CreateClient(uuid, RemoteConnectionType.GRPC, labels);

            this.namingGrpcConnectionEventListener = new NamingGrpcConnectionEventListener(_logger, this);

            Start(serverListFactory, serviceInfoHolder);
        }
Esempio n. 2
0
 private void Start(IServerListFactory serverListFactory, ServiceInfoHolder serviceInfoHolder)
 {
     rpcClient.Init(serverListFactory);
     rpcClient.Start();
     rpcClient.RegisterServerPushResponseHandler(new NamingPushRequestHandler(serviceInfoHolder));
     rpcClient.RegisterConnectionListener(namingGrpcConnectionEventListener);
 }
Esempio n. 3
0
        public NamingHttpClientProxy(
            ILogger logger,
            string namespaceId,
            SecurityProxy securityProxy,
            ServerListManager serverListManager,
            NacosSdkOptions options,
            ServiceInfoHolder serviceInfoHolder,
            IHttpClientFactory clientFactory = null)
        {
            this._logger           = logger;
            this._clientFactory    = clientFactory;
            this.serverListManager = serverListManager;
            this._securityProxy    = securityProxy;
            this._options          = options;
            this.SetServerPort(DEFAULT_SERVER_PORT);
            this.namespaceId = namespaceId;
            this.beatReactor = new BeatReactor(_logger, this, _options);

            // Don't create PushReceiver when using rpc, it will create a udp server
            if (!options.NamingUseRpc)
            {
                this.pushReceiver = new PushReceiver(_logger, serviceInfoHolder, _options);
            }

            this.serviceInfoHolder = serviceInfoHolder;
        }
        public FailoverReactor(ServiceInfoHolder serviceInfoHolder, string cacheDir)
        {
            this.serviceInfoHolder = serviceInfoHolder;
            this.failoverDir       = cacheDir + "/failover";

            this.Init();
        }
 public ServiceInfoUpdateService(NacosSdkOptions properties, ServiceInfoHolder serviceInfoHolder,
                                 INamingClientProxy namingClientProxy, InstancesChangeNotifier changeNotifier)
 {
     this.serviceInfoHolder = serviceInfoHolder;
     this.namingClientProxy = namingClientProxy;
     this.changeNotifier    = changeNotifier;
 }
Esempio n. 6
0
 public ServiceInfoUpdateService(ILogger logger, NacosSdkOptions properties, ServiceInfoHolder serviceInfoHolder,
                                 INamingClientProxy namingClientProxy, InstancesChangeNotifier changeNotifier)
 {
     this._logger            = logger;
     this._timerMap          = new ConcurrentDictionary <string, Timer>();
     this._serviceInfoHolder = serviceInfoHolder;
     this._namingClientProxy = namingClientProxy;
     this._changeNotifier    = changeNotifier;
 }
Esempio n. 7
0
 public NacosNamingService(
     ILoggerFactory loggerFactory,
     IOptions <NacosSdkOptions> optionAccs)
 {
     _logger                 = loggerFactory.CreateLogger <NacosNamingService>();
     _options                = optionAccs.Value;
     _namespace              = _options.Namespace;
     this._changeNotifier    = new InstancesChangeNotifier();
     this._serviceInfoHolder = new ServiceInfoHolder(_logger, _namespace, _options, _changeNotifier);
     this._clientProxy       = new NamingClientProxyDelegate(_logger, _namespace, _serviceInfoHolder, _options, _changeNotifier);
 }
 public NamingClientProxyDelegate(ILogger logger, string @namespace, ServiceInfoHolder serviceInfoHolder, NacosSdkOptions options, InstancesChangeNotifier changeNotifier)
 {
     this._options          = options;
     this.serverListManager = new ServerListManager(logger, options);
     this.serviceInfoHolder = serviceInfoHolder;
     this.securityProxy     = new SecurityProxy(options, logger);
     InitSecurityProxy();
     this._serviceInfoUpdateService = new ServiceInfoUpdateService(options, serviceInfoHolder, this, changeNotifier);
     this.grpcClientProxy           = new NamingGrpcClientProxy(logger, @namespace, securityProxy, serverListManager, options, serviceInfoHolder);
     this.httpClientProxy           = new NamingHttpClientProxy(logger, @namespace, securityProxy, serverListManager, options, serviceInfoHolder);
 }
Esempio n. 9
0
        public PushReceiver(ILogger logger, ServiceInfoHolder serviceInfoHolder, NacosSdkOptions options)
        {
            this._logger            = logger;
            this._serviceInfoHolder = serviceInfoHolder;

            // if using grpc, do not setup a udp client here.
            if (!options.NamingUseRpc)
            {
                Task.Factory.StartNew(
                    async() => await RunAsync(), TaskCreationOptions.LongRunning);
            }
        }
Esempio n. 10
0
        public FailoverReactor(ILogger logger, ServiceInfoHolder serviceInfoHolder, string cacheDir)
        {
            this._logger            = logger;
            this._serviceInfoHolder = serviceInfoHolder;
            this._failoverDir       = Path.Combine(cacheDir, FAILOVER_DIR);

            _switchRefresherTimer = new Timer(
                async x => await RunSwitchRefresh().ConfigureAwait(false), null, 0, 5000);

            _diskFileWriterTimer = new Timer(
                async x => await RunDiskFileWrite().ConfigureAwait(false), null, TimeSpan.FromMinutes(30), TimeSpan.FromMinutes(DAY_PERIOD_MINUTES));

            _timer = new Timer(
                async x => await RunUpdateBackupFile().ConfigureAwait(false), null, TimeSpan.FromMilliseconds(10000), Timeout.InfiniteTimeSpan);
        }
Esempio n. 11
0
 public NamingPushRequestHandler(ServiceInfoHolder serviceInfoHolder)
 {
     this._serviceInfoHolder = serviceInfoHolder;
 }