Exemple #1
0
        public RpcNode(RpcActor localActor,
                       IActorDirectory actorDirectory,
                       IServiceCatalogProvider serviceCatalog,
                       IServiceDirectory serviceDirectory,
                       IServiceProxyGenerator proxyGenerator,
                       RpcMethodFixture methodFixture)
            : base(localActor)
        {
            if (actorDirectory == null)
            {
                throw new ArgumentNullException("actorDirectory");
            }
            if (serviceCatalog == null)
            {
                throw new ArgumentNullException("serviceCatalog");
            }
            if (serviceDirectory == null)
            {
                throw new ArgumentNullException("serviceDirectory");
            }
            if (proxyGenerator == null)
            {
                throw new ArgumentNullException("proxyGenerator");
            }
            if (methodFixture == null)
            {
                throw new ArgumentNullException("methodFixture");
            }

            _actorDirectory   = actorDirectory;
            _serviceCatalog   = serviceCatalog;
            _serviceDirectory = serviceDirectory;
            _proxyGenerator   = proxyGenerator;
            _methodFixture    = methodFixture;
        }
Exemple #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();
        }
        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();
        }
Exemple #4
0
        public RpcServer(RpcActor localActor, IRateLimiter rateLimiter, IActorDirectory actorDirectory, IServiceCatalogProvider serviceCatalog, IServiceDirectory serviceDirectory, RpcMethodFixture methodFixture)
            : base(localActor, rateLimiter)
        {
            if (actorDirectory == null)
            {
                throw new ArgumentNullException("actorDirectory");
            }
            if (serviceCatalog == null)
            {
                throw new ArgumentNullException("serviceCatalog");
            }
            if (serviceDirectory == null)
            {
                throw new ArgumentNullException("serviceDirectory");
            }
            if (methodFixture == null)
            {
                throw new ArgumentNullException("methodFixture");
            }

            _actorDirectory   = actorDirectory;
            _serviceCatalog   = serviceCatalog;
            _serviceDirectory = serviceDirectory;
            _methodFixture    = methodFixture;
        }
Exemple #5
0
 public RpcClient(RpcActor localActor, IActorDirectory actorDirectory, IServiceProxyGenerator proxyGenerator)
     : this(localActor, actorDirectory, proxyGenerator,
            new RpcMethodFixture(
                new MethodLocatorExtractor(),
                new MethodArgumentEncoder(RpcActor.DefaultObjectEncoder),
                new MethodArgumentDecoder(RpcActor.DefaultObjectDecoder)))
 {
 }
Exemple #6
0
 public RpcServer(RpcActor localActor, IActorDirectory actorDirectory, IServiceCatalogProvider serviceCatalog, IServiceDirectory serviceDirectory)
     : this(localActor, actorDirectory, serviceCatalog, serviceDirectory,
            new RpcMethodFixture(
                new MethodLocatorExtractor(),
                new MethodArgumentEncoder(RpcActor.DefaultObjectEncoder),
                new MethodArgumentDecoder(RpcActor.DefaultObjectDecoder)))
 {
 }
Exemple #7
0
        public void Bootup(IActorDirectory directory)
        {
            if (directory == null)
            {
                throw new ArgumentNullException("directory");
            }
            if (this.Active)
            {
                throw new InvalidOperationException(
                          string.Format("Local actor [{0}] has already been booted up.", this.Identity));
            }

            _log.DebugFormat("Claim local actor [{0}].", this.Identity);

            if (_directory != null)
            {
                throw new InvalidOperationException("Actor directory has already been assigned.");
            }
            _directory = directory;

            _manager = new ActorChannelManager(_directory, new ActorChannelFactory(_directory, this.ChannelConfiguration));
            _manager.ChannelConnected    += OnActorChannelConnected;
            _manager.ChannelDisconnected += OnActorChannelDisconnected;
            _manager.ChannelDataReceived += OnActorChannelDataReceived;

            try
            {
                _manager.ActivateLocalActor(this.Identity);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                Shutdown();
                throw new InvalidOperationException(
                          string.Format("Cannot initiate the local actor [{0}] during bootup.", this.Identity));
            }

            try
            {
                if (!_directory.Active)
                {
                    _directory.Open();
                    _directory.Register(this.Identity);
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                Shutdown();
                throw new InvalidOperationException(
                          string.Format("Cannot connect to actor directory during bootup, [{0}].", this.Identity));
            }
        }
Exemple #8
0
        public ActorChannelManager(IActorDirectory directory, ActorChannelFactory factory)
        {
            if (directory == null)
            {
                throw new ArgumentNullException("directory");
            }
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }

            _directory = directory;
            _factory   = factory;

            _directory.ActorsChanged += OnDirectoryActorsChanged;
        }
Exemple #9
0
        public ActorChannelFactory(
            IActorDirectory directory,
            ActorChannelConfiguration channelConfiguration)
        {
            if (directory == null)
            {
                throw new ArgumentNullException("directory");
            }
            if (channelConfiguration == null)
            {
                throw new ArgumentNullException("channelConfiguration");
            }

            _directory            = directory;
            _channelConfiguration = channelConfiguration;
        }
Exemple #10
0
 public void Shutdown()
 {
     if (_manager != null)
     {
         _manager.Connected    -= OnActorConnected;
         _manager.Disconnected -= OnActorDisconnected;
         _manager.DataReceived -= OnActorDataReceived;
         _manager.CloseAllChannels();
         _manager = null;
     }
     if (_directory != null)
     {
         _directory.Close();
         _directory = null;
     }
 }
Exemple #11
0
 public void Shutdown()
 {
     if (_manager != null)
     {
         _manager.CloseAllChannels();
         _manager.ChannelConnected    -= OnActorChannelConnected;
         _manager.ChannelDisconnected -= OnActorChannelDisconnected;
         _manager.ChannelDataReceived -= OnActorChannelDataReceived;
         _manager = null;
     }
     if (_directory != null)
     {
         _directory.Deregister(this.Identity);
         _directory.Close();
         _directory = null;
     }
 }
Exemple #12
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));
        }
Exemple #13
0
        public RpcClient(RpcActor localActor, IRateLimiter rateLimiter, IActorDirectory actorDirectory, IServiceProxyGenerator proxyGenerator, RpcMethodFixture methodFixture)
            : base(localActor, rateLimiter)
        {
            if (actorDirectory == null)
            {
                throw new ArgumentNullException("actorDirectory");
            }
            if (proxyGenerator == null)
            {
                throw new ArgumentNullException("proxyGenerator");
            }
            if (methodFixture == null)
            {
                throw new ArgumentNullException("methodFixture");
            }

            _actorDirectory = actorDirectory;
            _proxyGenerator = proxyGenerator;
            _methodFixture  = methodFixture;
        }
Exemple #14
0
 public void Bootup(IActorDirectory directory)
 {
     _localActor.Bootup(directory);
 }
Exemple #15
0
 public void Bootup(IActorDirectory directory)
 {
     this.Actor.Bootup(directory);
 }