コード例 #1
0
        public static ISiloBuilder UseAppConfiguration(this ISiloBuilder siloHost, AppSiloBuilderContext context)
        {
            var appInfo = context.AppInfo;

            siloHost
            .AddMemoryGrainStorage(OrleansConstants.GrainMemoryStorage)
            .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = appInfo.ClusterId;
                options.ServiceId = appInfo.Name;
            });

            if (context.HostBuilderContext.HostingEnvironment.IsDevelopment())
            {
                siloHost.UseDevelopment(context);
            }
            if (appInfo.IsDockerized)
            {
                siloHost.UseDockerSwarm(context);
            }
            else
            {
                siloHost.UseDevelopmentClustering(context);
            }

            return(siloHost);
        }
コード例 #2
0
        private static ISiloBuilder UseDevelopment(this ISiloBuilder siloHost, AppSiloBuilderContext context)
        {
            siloHost
            .ConfigureServices(services =>
            {
                //services.Configure<GrainCollectionOptions>(options => { options.CollectionAge = TimeSpan.FromMinutes(1.5); });
            });
            //.Configure<ClusterMembershipOptions>(options => options.ExpectedClusterSize = 1);

            return(siloHost);
        }
コード例 #3
0
        private static ISiloBuilder UseDockerSwarm(this ISiloBuilder siloHost, AppSiloBuilderContext context)
        {
            var siloPort = context.SiloOptions.SiloPort;

            var ips         = Dns.GetHostAddresses(Dns.GetHostName());
            var defaultIpV4 = ips.First(x => x.AddressFamily == AddressFamily.InterNetwork);

            return(siloHost
                   .ConfigureEndpoints(
                       defaultIpV4,
                       siloPort,
                       context.SiloOptions.GatewayPort,
                       listenOnAnyHostAddress: true
                       ));
        }
コード例 #4
0
        private static ISiloBuilder UseDevelopmentClustering(this ISiloBuilder siloHost, AppSiloBuilderContext context)
        {
            var siloAddress = IPAddress.Loopback;
            var siloPort    = context.SiloOptions.SiloPort;
            var gatewayPort = context.SiloOptions.GatewayPort;

            return(siloHost
                   .UseLocalhostClustering(siloPort: siloPort, gatewayPort: gatewayPort)
                   //.UseDevelopmentClustering(options => options.PrimarySiloEndpoint = new IPEndPoint(siloAddress, siloPort))
                   //.ConfigureEndpoints(siloAddress, siloPort, gatewayPort) //, listenOnAnyHostAddress: true)
                   );
        }