Пример #1
0
        private async Task TestEndpointOfflineInner(IServiceEndpointManager manager, IEndpointRouter router, bool migratable)
        {
            var containers = new List <TestServiceConnectionContainer>();

            var container = new TestMultiEndpointServiceConnectionContainer("hub", e =>
            {
                var c = new TestServiceConnectionContainer(new List <IServiceConnection>
                {
                    new TestSimpleServiceConnection(),
                    new TestSimpleServiceConnection()
                });
                c.MockOffline = true;
                containers.Add(c);
                return(c);
            }, manager, router, NullLoggerFactory.Instance);

            foreach (var c in containers)
            {
                Assert.False(c.IsOffline);
            }

            var expected = container.OfflineAsync(migratable);
            var actual   = await Task.WhenAny(
                expected,
                Task.Delay(TimeSpan.FromSeconds(1))
                );

            Assert.Equal(expected, actual);

            foreach (var c in containers)
            {
                Assert.True(c.IsOffline);
            }
        }
        internal MultiEndpointServiceConnectionContainer(
            string hub,
            Func <HubServiceEndpoint, IServiceConnectionContainer> generator,
            IServiceEndpointManager endpointManager,
            IMessageRouter router,
            ILoggerFactory loggerFactory)
        {
            if (generator == null)
            {
                throw new ArgumentNullException(nameof(generator));
            }

            _logger = loggerFactory?.CreateLogger <MultiEndpointServiceConnectionContainer>() ?? throw new ArgumentNullException(nameof(loggerFactory));

            // provides a copy to the endpoint per container
            _endpoints = endpointManager.GetEndpoints(hub);

            if (_endpoints.Count == 1)
            {
                _inner = generator(_endpoints[0]);
            }
            else
            {
                // router is required when endpoints > 1
                _router = router ?? throw new ArgumentNullException(nameof(router));
                ConnectionContainers = _endpoints.ToDictionary(s => (ServiceEndpoint)s, s => generator(s));
            }
        }
Пример #3
0
 public NegotiateHandler(IServiceEndpointManager endpointManager, IEndpointRouter router, IUserIdProvider userIdProvider, IOptions <ServiceOptions> options)
 {
     _endpointManager = endpointManager ?? throw new ArgumentNullException(nameof(endpointManager));
     _router          = router ?? throw new ArgumentNullException(nameof(router));
     _userIdProvider  = userIdProvider ?? throw new ArgumentNullException(nameof(userIdProvider));
     _claimsProvider  = options?.Value?.ClaimsProvider;
 }
Пример #4
0
 public NegotiateHandler(
     IOptions <HubOptions> globalHubOptions,
     IOptions <HubOptions <THub> > hubOptions,
     IServiceEndpointManager endpointManager,
     IEndpointRouter router,
     IUserIdProvider userIdProvider,
     IServerNameProvider nameProvider,
     IConnectionRequestIdProvider connectionRequestIdProvider,
     IOptions <ServiceOptions> options,
     IBlazorDetector blazorDetector,
     ILogger <NegotiateHandler <THub> > logger)
 {
     _logger                      = logger ?? throw new ArgumentNullException(nameof(logger));
     _endpointManager             = endpointManager ?? throw new ArgumentNullException(nameof(endpointManager));
     _router                      = router ?? throw new ArgumentNullException(nameof(router));
     _serverName                  = nameProvider?.GetName();
     _userIdProvider              = userIdProvider ?? throw new ArgumentNullException(nameof(userIdProvider));
     _connectionRequestIdProvider = connectionRequestIdProvider ?? throw new ArgumentNullException(nameof(connectionRequestIdProvider));
     _claimsProvider              = options?.Value?.ClaimsProvider;
     _diagnosticClientFilter      = options?.Value?.DiagnosticClientFilter;
     _blazorDetector              = blazorDetector ?? new DefaultBlazorDetector();
     _mode = options.Value.ServerStickyMode;
     _enableDetailedErrors   = globalHubOptions.Value.EnableDetailedErrors == true;
     _endpointsCount         = options.Value.Endpoints.Length;
     _maxPollInterval        = options.Value.MaxPollIntervalInSeconds;
     _transportTypeDetector  = options.Value.TransportTypeDetector;
     _customHandshakeTimeout = GetCustomHandshakeTimeout(hubOptions.Value.HandshakeTimeout ?? globalHubOptions.Value.HandshakeTimeout);
     _hubName = typeof(THub).Name;
 }
        public ServiceHubDispatcher(
            IServiceProtocol serviceProtocol,
            IHubContext <THub> context,
            IServiceConnectionManager <THub> serviceConnectionManager,
            IClientConnectionManager clientConnectionManager,
            IServiceEndpointManager serviceEndpointManager,
            IOptions <ServiceOptions> options,
            ILoggerFactory loggerFactory,
            IEndpointRouter router,
            IServerNameProvider nameProvider,
            ServerLifetimeManager serverLifetimeManager,
            IClientConnectionFactory clientConnectionFactory,
            IServiceEventHandler serviceEventHandler)
        {
            _serviceProtocol          = serviceProtocol;
            _serviceConnectionManager = serviceConnectionManager;
            _clientConnectionManager  = clientConnectionManager;
            _serviceEndpointManager   = serviceEndpointManager;
            _options = options != null ? options.Value : throw new ArgumentNullException(nameof(options));

            Context = context;

            _router                  = router ?? throw new ArgumentNullException(nameof(router));
            _loggerFactory           = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
            _logger                  = loggerFactory.CreateLogger <ServiceHubDispatcher <THub> >();
            _clientConnectionFactory = clientConnectionFactory;
            _nameProvider            = nameProvider;
            _hubName                 = typeof(THub).Name;
            _serviceEventHandler     = serviceEventHandler;

            serverLifetimeManager?.Register(ShutdownAsync);
        }
Пример #6
0
        public MockServiceHubDispatcher(
            IServiceProtocol serviceProtocol,
            IHubContext <THub> context,
            IServiceConnectionManager <THub> serviceConnectionManager,
            IClientConnectionManager clientConnectionManager,
            IServiceEndpointManager serviceEndpointManager,
            IOptions <ServiceOptions> options,
            ILoggerFactory loggerFactory,
            IEndpointRouter router,
            IServerNameProvider nameProvider,
            ServerLifetimeManager serverLifetimeManager,
            IClientConnectionFactory clientConnectionFactory) : base(
                serviceProtocol,
                context,
                serviceConnectionManager,
                clientConnectionManager,
                serviceEndpointManager,
                options,
                loggerFactory,
                router,
                nameProvider,
                serverLifetimeManager,
                clientConnectionFactory,
                null)
        {
            MockService = new ConnectionTrackingMockService();

            // just store copies of these locally to keep the base class' accessor modifiers intact
            _loggerFactory           = loggerFactory;
            _clientConnectionManager = clientConnectionManager;
            _serviceProtocol         = serviceProtocol;
            _clientConnectionFactory = clientConnectionFactory;
        }
Пример #7
0
 public MultiEndpointConnectionContainerFactory(IServiceConnectionFactory connectionFactory, ILoggerFactory loggerFactory, IServiceEndpointManager serviceEndpointManager, IOptions <ContextOptions> options, IEndpointRouter router = null)
 {
     _connectionFactory = connectionFactory;
     _loggerFactory     = loggerFactory;
     _endpointManager   = serviceEndpointManager;
     _connectionCount   = options.Value.ConnectionCount;
     _router            = router;
 }
Пример #8
0
 public NegotiateHandler(IServiceEndpointManager endpointManager, IEndpointRouter router, IUserIdProvider userIdProvider, IServerNameProvider nameProvider, IOptions <ServiceOptions> options)
 {
     _endpointManager = endpointManager ?? throw new ArgumentNullException(nameof(endpointManager));
     _router          = router ?? throw new ArgumentNullException(nameof(router));
     _serverName      = nameProvider?.GetName();
     _userIdProvider  = userIdProvider ?? throw new ArgumentNullException(nameof(userIdProvider));
     _claimsProvider  = options?.Value?.ClaimsProvider;
     _mode            = options.Value.ServerStickyMode;
 }
            public TestMultiEndpointServiceConnectionContainer(string hub,
                                                               Func <HubServiceEndpoint, IServiceConnectionContainer> generator,
                                                               IServiceEndpointManager endpoint,
                                                               IEndpointRouter router,
                                                               ILoggerFactory loggerFactory

                                                               ) : base(hub, generator, endpoint, router, loggerFactory)
            {
            }
 public ServiceHubContextImpl(string hubName, IHubContext <Hub> hubContext, IServiceHubLifetimeManager lifetimeManager, IServiceProvider serviceProvider, NegotiateProcessor negotiateProcessor, IServiceEndpointManager endpointManager)
 {
     _hubName            = hubName;
     _hubContext         = hubContext;
     _lifetimeManager    = lifetimeManager;
     UserGroups          = new UserGroupsManager(lifetimeManager);
     ServiceProvider     = serviceProvider;
     _negotiateProcessor = negotiateProcessor;
     _endpointManager    = endpointManager;
 }
Пример #11
0
 public NegotiateMiddleware(OwinMiddleware next, HubConfiguration configuration, string appName, IServiceEndpointManager endpointManager, IEndpointRouter router, ServiceOptions options, ILoggerFactory loggerFactory)
     : base(next)
 {
     _provider        = configuration.Resolver.Resolve <IUserIdProvider>();
     _appName         = appName ?? throw new ArgumentNullException(nameof(appName));
     _claimsProvider  = options?.ClaimsProvider;
     _endpointManager = endpointManager ?? throw new ArgumentNullException(nameof(endpointManager));
     _router          = router ?? throw new ArgumentNullException(nameof(router));
     _logger          = loggerFactory?.CreateLogger <NegotiateMiddleware>() ?? throw new ArgumentNullException(nameof(loggerFactory));
 }
 public ServiceConnectionContainerFactory(
     IServiceConnectionFactory serviceConnectionFactory,
     IServiceEndpointManager serviceEndpointManager,
     IMessageRouter router,
     IServiceEndpointOptions options,
     ILoggerFactory loggerFactory)
 {
     _serviceConnectionFactory = serviceConnectionFactory;
     _serviceEndpointManager   = serviceEndpointManager ?? throw new ArgumentNullException(nameof(serviceEndpointManager));
     _router        = router ?? throw new ArgumentNullException(nameof(router));
     _options       = options;
     _loggerFactory = loggerFactory;
 }
Пример #13
0
 public NegotiateHandler(
     IOptions <HubOptions> hubOptions,
     IServiceEndpointManager endpointManager, IEndpointRouter router, IUserIdProvider userIdProvider, IServerNameProvider nameProvider, IConnectionRequestIdProvider connectionRequestIdProvider, IOptions <ServiceOptions> options)
 {
     _endpointManager             = endpointManager ?? throw new ArgumentNullException(nameof(endpointManager));
     _router                      = router ?? throw new ArgumentNullException(nameof(router));
     _serverName                  = nameProvider?.GetName();
     _userIdProvider              = userIdProvider ?? throw new ArgumentNullException(nameof(userIdProvider));
     _connectionRequestIdProvider = connectionRequestIdProvider ?? throw new ArgumentNullException(nameof(connectionRequestIdProvider));
     _claimsProvider              = options?.Value?.ClaimsProvider;
     _mode = options.Value.ServerStickyMode;
     _enableDetailedErrors = hubOptions.Value.EnableDetailedErrors == true;
 }
 public MultiEndpointServiceConnectionContainerFactory(
     IServiceConnectionFactory serviceConnectionFactory,
     IServiceEndpointManager serviceEndpointManager,
     IEndpointRouter router,
     IOptions <ServiceOptions> options,
     IServerNameProvider nameProvider,
     ILoggerFactory loggerFactory)
 {
     _loggerFactory            = loggerFactory;
     _router                   = router ?? throw new ArgumentNullException(nameof(router));
     _serviceConnectionFactory = serviceConnectionFactory;
     _nameProvider             = nameProvider;
     _options                  = options?.Value;
     _serviceEndpointManager   = serviceEndpointManager ?? throw new ArgumentNullException(nameof(serviceEndpointManager));
 }
Пример #15
0
 public NegotiateMiddleware(OwinMiddleware next, HubConfiguration configuration, string appName, IServiceEndpointManager endpointManager, IEndpointRouter router, ServiceOptions options, IServerNameProvider serverNameProvider, IConnectionRequestIdProvider connectionRequestIdProvider, ILoggerFactory loggerFactory)
     : base(next)
 {
     _configuration               = configuration;
     _provider                    = configuration.Resolver.Resolve <IUserIdProvider>();
     _appName                     = appName ?? throw new ArgumentNullException(nameof(appName));
     _claimsProvider              = options?.ClaimsProvider;
     _endpointManager             = endpointManager ?? throw new ArgumentNullException(nameof(endpointManager));
     _router                      = router ?? throw new ArgumentNullException(nameof(router));
     _connectionRequestIdProvider = connectionRequestIdProvider ?? throw new ArgumentNullException(nameof(connectionRequestIdProvider));
     _logger                      = loggerFactory?.CreateLogger <NegotiateMiddleware>() ?? throw new ArgumentNullException(nameof(loggerFactory));
     _serverName                  = serverNameProvider?.GetName();
     _mode = options.ServerStickyMode;
     _enableDetailedErrors = configuration.EnableDetailedErrors;
 }
 public MultiEndpointServiceConnectionContainer(
     IServiceConnectionFactory serviceConnectionFactory,
     string hub,
     int count,
     IServiceEndpointManager endpointManager,
     IMessageRouter router,
     ILoggerFactory loggerFactory
     ) : this(
         hub,
         endpoint => CreateContainer(serviceConnectionFactory, endpoint, count, loggerFactory),
         endpointManager,
         router,
         loggerFactory
         )
 {
 }
Пример #17
0
 public ServiceHubDispatcher(IReadOnlyList <string> hubNames, IServiceProtocol protocol,
                             IServiceConnectionManager serviceConnectionManager, IClientConnectionManager clientConnectionManager,
                             IServiceEndpointManager serviceEndpointManager,
                             IEndpointRouter router,
                             IOptions <ServiceOptions> options, ILoggerFactory loggerFactory)
 {
     _hubNames                 = hubNames;
     _name                     = $"{nameof(ServiceHubDispatcher)}[{string.Join(",", hubNames)}]";
     _loggerFactory            = loggerFactory;
     _protocol                 = protocol ?? throw new ArgumentNullException(nameof(protocol));
     _router                   = router ?? throw new ArgumentNullException(nameof(router));
     _serviceConnectionManager = serviceConnectionManager ?? throw new ArgumentNullException(nameof(serviceConnectionManager));
     _clientConnectionManager  = clientConnectionManager ?? throw new ArgumentNullException(nameof(clientConnectionManager));
     _options                  = options?.Value;
     _serviceEndpointManager   = serviceEndpointManager ?? throw new ArgumentNullException(nameof(serviceEndpointManager));
     _logger                   = _loggerFactory.CreateLogger <ServiceHubDispatcher>();
 }
Пример #18
0
 public ServiceConnectionContainerFactory(
     IServiceConnectionFactory serviceConnectionFactory,
     IServiceEndpointManager serviceEndpointManager,
     IMessageRouter router,
     IServiceEndpointOptions options,
     IServerNameProvider nameProvider,
     IClientConnectionLifetimeManager lifetime,
     ILoggerFactory loggerFactory)
 {
     _serviceConnectionFactory = serviceConnectionFactory;
     _serviceEndpointManager   = serviceEndpointManager ?? throw new ArgumentNullException(nameof(serviceEndpointManager));
     _router        = router ?? throw new ArgumentNullException(nameof(router));
     _options       = options;
     _nameProvider  = nameProvider;
     _lifetime      = lifetime;
     _loggerFactory = loggerFactory;
 }
Пример #19
0
        public RestHealthCheckService(RestClientFactory clientFactory, IServiceEndpointManager serviceEndpointManager, ILogger <RestHealthCheckService> logger, string hubName, IOptions <HealthCheckOption> options)
        {
            var checkOptions = options.Value;

            _enable = serviceEndpointManager.Endpoints.Count > 1 || checkOptions.EnabledForSingleEndpoint;
            if (_enable)
            {
                _clientFactory          = clientFactory;
                _serviceEndpointManager = serviceEndpointManager;
                _logger  = logger;
                _hubName = hubName;

                _checkInterval = checkOptions.CheckInterval.GetValueOrDefault(_checkInterval);
                _retryInterval = checkOptions.RetryInterval.GetValueOrDefault(_retryInterval);
                _timer         = new TimerAwaitable(_checkInterval, _checkInterval);
            }
        }
Пример #20
0
 public MultiEndpointServiceConnectionContainer(
     IServiceConnectionFactory serviceConnectionFactory,
     string hub,
     int count,
     IServiceEndpointManager endpointManager,
     IMessageRouter router,
     IServerNameProvider nameProvider,
     IClientConnectionLifetimeManager lifetime,
     ILoggerFactory loggerFactory
     ) : this(
         hub,
         endpoint => CreateContainer(serviceConnectionFactory, endpoint, count, loggerFactory),
         endpointManager,
         router,
         lifetime,
         loggerFactory
         )
 {
 }
Пример #21
0
        public ServiceHubDispatcher(IServiceProtocol serviceProtocol,
                                    IServiceConnectionManager <THub> serviceConnectionManager,
                                    IClientConnectionManager clientConnectionManager,
                                    IServiceEndpointManager serviceEndpointManager,
                                    IOptions <ServiceOptions> options,
                                    ILoggerFactory loggerFactory,
                                    IEndpointRouter router,
                                    IClientConnectionFactory clientConnectionFactory)
        {
            _serviceProtocol          = serviceProtocol;
            _serviceConnectionManager = serviceConnectionManager;
            _clientConnectionManager  = clientConnectionManager;
            _serviceEndpointManager   = serviceEndpointManager;
            _options = options != null ? options.Value : throw new ArgumentNullException(nameof(options));

            _router                  = router ?? throw new ArgumentNullException(nameof(router));
            _loggerFactory           = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
            _logger                  = loggerFactory.CreateLogger <ServiceHubDispatcher <THub> >();
            _clientConnectionFactory = clientConnectionFactory;
            _hubName                 = typeof(THub).Name;
        }
Пример #22
0
 public NegotiateHandler(
     IOptions <HubOptions> hubOptions,
     IServiceEndpointManager endpointManager,
     IEndpointRouter router,
     IUserIdProvider userIdProvider,
     IServerNameProvider nameProvider,
     IConnectionRequestIdProvider connectionRequestIdProvider,
     IOptions <ServiceOptions> options,
     IBlazorDetector blazorDetector)
 {
     _endpointManager             = endpointManager ?? throw new ArgumentNullException(nameof(endpointManager));
     _router                      = router ?? throw new ArgumentNullException(nameof(router));
     _serverName                  = nameProvider?.GetName();
     _userIdProvider              = userIdProvider ?? throw new ArgumentNullException(nameof(userIdProvider));
     _connectionRequestIdProvider = connectionRequestIdProvider ?? throw new ArgumentNullException(nameof(connectionRequestIdProvider));
     _claimsProvider              = options?.Value?.ClaimsProvider;
     _diagnosticClientFilter      = options?.Value?.DiagnosticClientFilter;
     _blazorDetector              = blazorDetector ?? new DefaultBlazorDetector();
     _mode = options.Value.ServerStickyMode;
     _enableDetailedErrors = hubOptions.Value.EnableDetailedErrors == true;
     _endpointsCount       = options.Value.Endpoints.Length;
     _maxPollInterval      = options.Value.MaxPollIntervalInSeconds;
 }
        public MultiEndpointServiceConnectionContainer(Func <ServiceEndpoint, IServiceConnectionContainer> generator, IServiceEndpointManager endpointManager, IEndpointRouter router, ILoggerFactory loggerFactory)
        {
            if (generator == null)
            {
                throw new ArgumentNullException(nameof(generator));
            }

            _endpointManager = endpointManager ?? throw new ArgumentNullException(nameof(endpointManager));
            _logger          = loggerFactory?.CreateLogger <MultiEndpointServiceConnectionContainer>() ?? NullLogger <MultiEndpointServiceConnectionContainer> .Instance;

            var endpoints = endpointManager.Endpoints;

            if (endpoints.Length == 1)
            {
                _inner = generator(endpoints[0]);
            }
            else
            {
                // router is required when endpoints > 1
                _router     = router ?? throw new ArgumentNullException(nameof(router));
                Connections = endpoints.ToDictionary(s => s, s => generator(s));
            }
        }
Пример #24
0
 public NegotiateProcessor(IServiceEndpointManager serviceEndpointManager, IEndpointRouter router)
 {
     _serviceEndpointManager = serviceEndpointManager;
     _router = router;
 }
Пример #25
0
        public MultiEndpointServiceConnectionContainer(Func <ServiceEndpoint, IServiceConnectionContainer> generator, IServiceEndpointManager endpointManager, IMessageRouter router, ILoggerFactory loggerFactory)
        {
            if (generator == null)
            {
                throw new ArgumentNullException(nameof(generator));
            }

            _logger = loggerFactory?.CreateLogger <MultiEndpointServiceConnectionContainer>() ?? NullLogger <MultiEndpointServiceConnectionContainer> .Instance;

            // provides a copy to the endpoint per container
            _endpoints = endpointManager.Endpoints.Select(s => new ServiceEndpoint(s)).ToArray();

            if (_endpoints.Count == 1)
            {
                _inner = generator(_endpoints[0]);
            }
            else
            {
                // router is required when endpoints > 1
                _router     = router ?? throw new ArgumentNullException(nameof(router));
                Connections = _endpoints.ToDictionary(s => s, s => generator(s));
            }
        }
Пример #26
0
        private static ServiceHubDispatcher PrepareAndGetDispatcher(HubConfiguration configuration, ServiceOptions options, IServiceEndpointManager endpoint, IEndpointRouter router, string applicationName, IReadOnlyList <string> hubs, ILoggerFactory loggerFactory)
        {
            // TODO: Using IOptions looks wierd, thinking of a way removing it
            // share the same object all through
            var serviceOptions = Options.Create(options);

            // For safety, ALWAYS register abstract classes or interfaces
            // Some third-party DI frameworks such as Ninject, implicit self-binding concrete types:
            // https://github.com/ninject/ninject/wiki/dependency-injection-with-ninject#skipping-the-type-binding-bit--implicit-self-binding-of-concrete-types
            configuration.Resolver.Register(typeof(IOptions <ServiceOptions>), () => serviceOptions);

            var serviceProtocol = new ServiceProtocol();

            configuration.Resolver.Register(typeof(IServiceProtocol), () => serviceProtocol);

            var scm = new ServiceConnectionManager(applicationName, hubs);

            configuration.Resolver.Register(typeof(Microsoft.Azure.SignalR.AspNet.IServiceConnectionManager), () => scm);

            var ccm = new ClientConnectionManager(configuration);

            configuration.Resolver.Register(typeof(IClientConnectionManager), () => ccm);

            var atm = new AzureTransportManager(configuration.Resolver);

            configuration.Resolver.Register(typeof(ITransportManager), () => atm);

            var parser = new SignalRMessageParser(hubs, configuration.Resolver);

            configuration.Resolver.Register(typeof(IMessageParser), () => parser);

            var smb = new ServiceMessageBus(configuration.Resolver);

            configuration.Resolver.Register(typeof(IMessageBus), () => smb);

            if (hubs?.Count > 0)
            {
                return(new ServiceHubDispatcher(hubs, serviceProtocol, scm, ccm, endpoint, router, serviceOptions, loggerFactory));
            }
            else
            {
                loggerFactory.CreateLogger <IAppBuilder>().Log(LogLevel.Warning, "No hubs found.");
                return(null);
            }
        }
Пример #27
0
 public ServiceManager(RestClientFactory restClientFactory, ServiceHubContextFactory serviceHubContextFactory, IServiceEndpointManager endpointManager, IServiceProvider serviceProvider)
 {
     _restClientFactory        = restClientFactory;
     _serviceHubContextFactory = serviceHubContextFactory;
     _serviceProvider          = serviceProvider;
     _endpoint         = endpointManager.Endpoints.Single().Key;
     _endpointProvider = endpointManager.GetEndpointProvider(_endpoint);
 }
Пример #28
0
        private static IServiceConnectionContainer CreateContainer(IServiceConnectionFactory serviceConnectionFactory, ServiceEndpoint endpoint, string hub, int count, IServiceEndpointManager endpointManager, IServerNameProvider nameProvider, ILoggerFactory loggerFactory)
        {
            var provider          = endpointManager.GetEndpointProvider(endpoint);
            var connectionFactory = new ConnectionFactory(hub, provider, nameProvider, loggerFactory);

            if (endpoint.EndpointType == EndpointType.Primary)
            {
                return(new StrongServiceConnectionContainer(serviceConnectionFactory, connectionFactory, count, endpoint));
            }
            else
            {
                return(new WeakServiceConnectionContainer(serviceConnectionFactory, connectionFactory, count, endpoint));
            }
        }
Пример #29
0
 public ServiceManager(IReadOnlyCollection <ServiceDescriptor> services, IServiceProvider serviceProvider, RestClientFactory restClientFactory, IServiceEndpointManager endpointManager)
 {
     _services          = services;
     _serviceProvider   = serviceProvider;
     _restClientFactory = restClientFactory;
     _endpoint          = endpointManager.Endpoints.Keys.First();
     _endpointProvider  = endpointManager.GetEndpointProvider(_endpoint);
 }
Пример #30
0
        public ServiceManager(IReadOnlyCollection <ServiceDescriptor> services, IServiceProvider serviceProvider, RestClientFactory restClientFactory, IServiceEndpointManager endpointManager, IOptions <ServiceManagerOptions> options)
        {
            _services          = services;
            _serviceProvider   = serviceProvider;
            _restClientFactory = restClientFactory;
            var connectionString = options.Value.ConnectionString;

            if (!string.IsNullOrWhiteSpace(connectionString))
            {
                _endpoint         = new ServiceEndpoint(connectionString);
                _endpointProvider = endpointManager.GetEndpointProvider(_endpoint);
            }
        }