private static ClusterConfig GetClusterConfig(
            IClusterProvider clusterProvider,
            IIdentityLookup identityLookup
            )
        {
            var helloProps = Props.FromProducer(() => new WorkerActor());

            return(ClusterConfig
                   .Setup("mycluster", clusterProvider, identityLookup)
                   .WithClusterKind("hello", helloProps));
        }
        public DefaultClusterContext(IIdentityLookup identityLookup, PidCache pidCache, ClusterContextConfig config, CancellationToken killSwitch)
        {
            _identityLookup = identityLookup;
            _pidCache       = pidCache;

            _requestLogThrottle = Throttle.Create(
                config.MaxNumberOfEventsInRequestLogThrottlePeriod,
                config.RequestLogThrottlePeriod,
                i => Logger.LogInformation("Throttled {LogCount} TryRequestAsync logs", i)
                );
            _clock = new TaskClock(config.ActorRequestTimeout, TimeSpan.FromSeconds(1), killSwitch);
            _clock.Start();
        }
        public ExperimentalClusterContext(Cluster cluster)
        {
            _identityLookup = cluster.IdentityLookup;
            _pidCache       = cluster.PidCache;
            var config = cluster.Config;

            _requestLogThrottle = Throttle.Create(
                config.MaxNumberOfEventsInRequestLogThrottlePeriod,
                config.RequestLogThrottlePeriod,
                i => Logger.LogInformation("Throttled {LogCount} TryRequestAsync logs", i)
                );
            _clock = new TaskClock(config.ActorRequestTimeout, TimeSpan.FromSeconds(1), cluster.System.Shutdown);
            _clock.Start();
        }
Exemplo n.º 4
0
        public static (ClusterConfig, GrpcCoreRemoteConfig) CreateClusterConfig(IClusterSettings clusterSettings, IClusterProvider clusterProvider, IIdentityLookup identityLookup, IDescriptorProvider descriptorProvider, ILogger _logger)
        {
            //var portStr = Environment.GetEnvironmentVariable("PROTOPORT") ?? $"{RemoteConfigBase.AnyFreePort}";

            var clusterName = clusterSettings.ClusterName;

            var hostip         = Environment.GetEnvironmentVariable("PROTOHOST");
            var host           = clusterSettings.ClusterHost;
            var advertisedHost = clusterSettings.ClusterHost;
            var port           = clusterSettings.ClusterPort;

            if ("protohost".Equals(host))
            {
                host           = hostip;
                advertisedHost = hostip;
                _logger.LogDebug($"Using PROTOHOST");
            }
            _logger.LogDebug($"BindTo to {host} port {port}");
            _logger.LogDebug($"WithAdvertisedHost to {advertisedHost}");

            FileDescriptor[] descriptors = descriptorProvider.GetDescriptors();


            // TOOD: This doesn't seem to work. Why?
            List <ChannelOption> options = new List <ChannelOption>()
            {
                new ChannelOption(ChannelOptions.MaxSendMessageLength, (100 * 1024 * 1024)),
                new ChannelOption(ChannelOptions.MaxReceiveMessageLength, (100 * 1024 * 1024))
            };


            GrpcCoreRemoteConfig remoteConfig = GrpcCoreRemoteConfig.BindTo(host, port)
                                                .WithEndpointWriterMaxRetries(0)
                                                .WithRemoteDiagnostics(true)
                                                .WithAdvertisedHost(advertisedHost)
                                                .WithProtoMessages(descriptors)
                                                .WithChannelOptions(options);

            var clusterConfig = ClusterConfig.Setup(clusterName, clusterProvider, identityLookup);

            return(clusterConfig, remoteConfig);
        }