Esempio n. 1
0
        static void Main(string[] args)
        {
            var loggerFactory = new LoggerFactory();

            loggerFactory.AddProvider <ConsoleLoggerProvider>();
            Logger.LoggerFactory = loggerFactory;

            var builder = new ServiceHostBuilder();

            builder.ConfigureOptions <ClusterMembershipServiceOptions>(p =>
            {
                p.InsideAddress  = new SlioAddress("0.0.0.0", 64000);
                p.Backlog        = 10;
                p.MaxConnections = 100;
            });
            builder.ConfigureOptions <GatewayMembershipServiceOptions>(p =>
            {
                p.InsideAddress  = new SlioAddress("0.0.0.0", 64001);
                p.Backlog        = 10;
                p.MaxConnections = 100;
                p.Cluster        = new SlioAddress("0.0.0.0", 64000);
            });
            builder.AddSystemTarget <IClusterMembershipService, ClusterMembershipService>();
            builder.AddSystemTarget <IGatewayMembershipService, GatewayMembershipService>();

            builder.AddService <ISayService, SayService>(metadata: new ServiceMetadata()
            {
                ID = 45
            });
            builder.AddService <IHelloService, HelloService>();
            serviceHost = builder.Build();
            serviceHost.Lifecycle.WithStarted(nameof(Program), (token) =>
            {
                var serviceFactory = serviceHost.ServiceFactory;
                var helloService   = serviceFactory.GetSingleService <ISayService>();
                var metadata       = helloService.Metadata;
                var result         = helloService.Say("cxx");
            });

            serviceHost.Start();
            Console.WriteLine("started...");

            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var builder = new ServiceHostBuilder();

            builder.ConfigureOptions <ClusterMembershipServiceOptions>();
            builder.ConfigureOptions <GatewayMembershipServiceOptions>();
            builder.AddSystemTarget <IClusterMembershipService, ClusterMembershipService>();
            builder.AddSystemTarget <IGatewayMembershipService, GatewayMembershipService>();
            builder.AddService <IDataService, DataService>();

            serviceHost = builder.Build();
            serviceHost.Start();
            Console.WriteLine("started...");
            Console.ReadLine();
            serviceHost.Stop();
        }