예제 #1
0
        public RemoteStageServer(
            IServiceProvider services,
            IActorDirectory actorDirectory,
            IStageDirectory stageDirectory,
            LocalStage localStage,
            ILogger <RemoteStageServer> logger,
            ISocketServer socketServer,
            ITransportSerializer serializer,
            ITelemetry telemetry

            )
        {
            _services = services;

            _actorDirectory = actorDirectory;

            _stageDirectory = stageDirectory;

            _localStage = localStage;

            _socketServer = socketServer;

            _serializer = serializer;

            _logger = logger;

            _telemetry = telemetry;

            _remoteClient = new Lazy <RemoteStageClient>(() => {
                return(_services.GetRequiredService <RemoteStageClient>());
            });

            ProcessServerInput();
        }
예제 #2
0
        public RemoteStageClient(
            IServiceProvider services,
            IActorDirectory actorDirectory,
            IStageDirectory stageDirectory,
            LocalStage localStage,
            ISocketClient socketClient,
            ITransportSerializer serializer,
            RemoteStageServer stageServer,
            ITelemetry telemetry
            )
        {
            _services = services;

            _actorDirectory = actorDirectory;

            _stageDirectory = stageDirectory;

            _localStage = localStage;

            _socketClient = socketClient;

            _serializer = serializer;

            _stageServer = stageServer;

            _telemetry = telemetry;

            ProcessServerInput();
        }
예제 #3
0
        public void Configure()
        {
            ConfigureDefaults();

            _serviceProvider = _serviceCollection.BuildServiceProvider();

            _remoteClient = _serviceProvider.GetRequiredService <RemoteStageClient>();

            _stageDirectory = _serviceProvider.GetRequiredService <IStageDirectory>();

            _serializer = _serviceProvider.GetRequiredService <ITransportSerializer>();

            _telemetry = _serviceProvider.GetRequiredService <ITelemetry>();

            _configured = true;
        }
예제 #4
0
        public RedisActorDirectory(RedisConnectionFactory connectionFactory, IStageDirectory stageDirectory, IOptions <NanoServiceOptions> serviceOptions, ITransportSerializer serializer)
        {
            _connectionFactory = connectionFactory;
            _serviceOptions    = serviceOptions.Value;
            _serializer        = serializer;
            _stageDirectory    = stageDirectory;

            var cacheOptions = Microsoft.Extensions.Options.Options.Create <MemoryCacheOptions>(new MemoryCacheOptions()
            {
                CompactOnMemoryPressure = false
            });

            _memoryCache = new MemoryCache(cacheOptions);



            _scriptsLazy = new Lazy <RedisScripts>(() => { return(new RedisScripts(_database)); });
        }
예제 #5
0
        public LocalStage(
            IServiceProvider services,
            ITransportSerializer serializer,
            ITelemetry <LocalStage> telemetry,
            IActorDirectory actorDirectory,
            IStageDirectory stageDirectory,
            ILogger <LocalStage> logger,
            IOptions <NanoServiceOptions> serviceOptions,
            PubSubManager pubsub)
        {
            _services = services;

            _actorDirectory = actorDirectory;

            _stageDirectory = stageDirectory;

            _pubsub = pubsub;

            _serializer = serializer;

            StageGuid = Guid.NewGuid().ToString();

            _logger = logger;

            _telemetry      = telemetry;
            _serviceOptions = serviceOptions.Value;

            var stageDefaultProperty = new Dictionary <string, string>
            {
                { "StageId", StageGuid }
            };

            _telemetry.SetProperties(stageDefaultProperty);


            _reqSecondMeter = _telemetry.Meter(
                "Stage.Requests", TimeSpan.FromSeconds(60)
                );

            _actorInstancesMetric = _telemetry.Metric(
                "Stage.ActiveActorInstances");

            _deactivatedInstancesMeter = _telemetry.Meter("Stage.DeactivatedActorInstances", TimeSpan.FromSeconds(60));
        }
예제 #6
0
        public RedisSocketClient(
            IServiceProvider services,
            ITelemetry telemetry,
            ILogger <RedisSocketClient> logger,
            IStageDirectory stageDirectory,
            IOptions <NanoServiceOptions> serviceOptions,
            IOptions <RedisOptions> redisOptions)
        {
            this._services       = services;
            this._serviceOptions = serviceOptions.Value;
            this._redisOptions   = redisOptions.Value;
            this._stageDirectory = stageDirectory;
            this._telemetry      = telemetry;

            _logger = logger;

            _guid = Guid.NewGuid().ToString();



            Listen();
        }