コード例 #1
0
 public static IWebHost BuildWebHost(string[] args)
 {
     return(WebHost.CreateDefaultBuilder(args)
            .UseStartup <Startup>()
            .UseUrls("http://localhost:" + PortUtils.FindAvailablePortIncrementally(5050))
            .Build());
 }
コード例 #2
0
        public static IPublishSubscribe Auto(string clusterId)
        {
            ILoggerFactory loggerFactory = new LoggerFactory().AddConsole(LogLevel.Debug);

            Log.SetLoggerFactory(loggerFactory);
            ISerializer <byte[]> serializer = new MessagePackSerializer();
            IPublishSubscribe    pubSub     = new PublishSubscribeBuilder(new WireSerializer())
                                              .SetClusterName(clusterId)
                                              .SetSerializer(serializer)
                                              .SetLoggerFactory(loggerFactory)
                                              .ProtoActorPublishSubscribe()
                                              //.GrpcPublishSubscribe(seedsEndpointObservable: Observable.Return(new[]
                                              //{
                                              //	new DnsEndPoint("localhost", 35000),
                                              //	new DnsEndPoint("localhost", 35001),
                                              //	new DnsEndPoint("localhost", 35002),
                                              //	new DnsEndPoint("localhost", 35003)
                                              //}))
                                              .Build();

            //ClusterBuilder.RunSeededLocalCluster(clusterId);
            Cluster.Start("Abe", "localhost", PortUtils.FindAvailablePortIncrementally(36002), new ConsulProvider(new ConsulProviderOptions()));

            return(pubSub);
        }
コード例 #3
0
        public static IDisposable RunSeededLocalCluster(string clusterId = null,
                                                        int port         = 36100)
        {
            IPAddress ipAddress  = NetworkUtils.GetLocalIpAddress().First();
            int       serverPort = PortUtils.FindAvailablePortIncrementally(port);

            IPEndPoint[] seedsEndpoints = { new IPEndPoint(ipAddress, port), new IPEndPoint(ipAddress, serverPort) };
            global::Proto.Cluster.Cluster.Start(clusterId, ipAddress.ToString(), serverPort,
                                                new SeededLocalClusterProvider(Observable.Return(seedsEndpoints.Distinct())));
            return(new AnonymousDisposable(() => global::Proto.Cluster.Cluster.Shutdown()));
        }
コード例 #4
0
        public OrleansStartup(string clusterName)
        {
            ILoggerFactory       loggerFactory = new NullLoggerFactory();
            ISerializer <byte[]> serializer    = new MessagePackSerializer();

            PublishSubscribe = new PublishSubscribeBuilder(new WireSerializer())
                               .SetLoggerFactory(loggerFactory)
                               .SetSerializer(serializer)
                               .ProtoActorPublishSubscribe()
                               .Build();

            // Start ProtoActor Cluster
            int serverPort = PortUtils.FindAvailablePortIncrementally(41000);

            Cluster.Start("unique", "127.0.0.1", serverPort,
                          new SeededLocalClusterProvider(Observable.Return(new[] { new IPEndPoint(IPAddress.Loopback, 41000) })));
        }
コード例 #5
0
        private static void Main(string[] args)
        {
            int    serverPort    = PortUtils.FindAvailablePortIncrementally(18889);
            string serverAddress = $"ws://127.0.0.1:{serverPort}/ws";

            //WampHost host = new DefaultWampHost(serverAddress);
            DefaultWampAuthenticationHost host = new DefaultWampAuthenticationHost(serverAddress, new VergicWampAuthenticatorFactory());

            IWampHostedRealm realm = host.RealmContainer.GetRealmByName("vivego");

            realm.SessionCreated += Realm_SessionCreated;
            realm.SessionClosed  += Realm_SessionClosed;

            //EnableDistributedBackplane(realm);
            host.Open();

            DefaultWampChannelFactory channelFactory = new DefaultWampChannelFactory();
            IWampChannel wampChannel = channelFactory.CreateJsonChannel(serverAddress, "vivego", new TicketAuthenticator());

            wampChannel.Open().Wait();

            using (wampChannel.RealmProxy.Services
                   .GetSubject <object>("vivego")
                   .Subscribe(s => { Console.Out.WriteLine(s); }))
            {
                //while (true)
                {
                    string input = Console.ReadLine();

                    realm.TopicContainer.Publish(WampObjectFormatter.Value,
                                                 new PublishOptions(),
                                                 "vivego",
                                                 new object[] { "Helo" });
                }
            }

            wampChannel.Close();

            Console.ReadLine();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: vishalishere/vivego
        private static void Main()
        {
            OrleansStartup       orleansStartup = new OrleansStartup("clusterName");
            ClusterConfiguration siloConfig     = ClusterConfiguration
                                                  .LocalhostPrimarySilo(PortUtils.FindAvailablePortIncrementally(22222), PortUtils.FindAvailablePortIncrementally(40000))
                                                  .AddPublishSubscribeStreamProvider();

            siloConfig.AddMemoryStorageProvider("PubSubStore");
            ISiloHost siloHost = new SiloHostBuilder()
                                 .AddApplicationPart(typeof(TestGrain).Assembly)
                                 .UseConfiguration(siloConfig)
                                 .UseServiceProviderFactory(collection => orleansStartup.ConfigureServices(collection))
                                 .Build();

            ClientConfiguration clientConfiguration = ClientConfiguration
                                                      .LocalhostSilo()
                                                      .AddPublishSubscribeStreamProvider()
                                                      .ConnectTo(siloConfig);
            IClientBuilder clientBuilder = new ClientBuilder()
                                           .AddApplicationPart(typeof(TestGrain).Assembly)
                                           .UseConfiguration(clientConfiguration)
                                           .UseServiceProviderFactory(services => orleansStartup.ConfigureServices(services));

            using (orleansStartup.PublishSubscribe
                   .Observe <object>("*")
                   .Subscribe(_ => { Console.Out.WriteLine(_); }))
            {
                using (siloHost.Run())
                    using (IClusterClientEx clusterClient = clientBuilder.Run())
                    {
                        clusterClient.GetGrain <ITestGrain>(Guid.NewGuid()).Run().Wait();
                        //orleansStartup.PublishSubscribe.Publish("from Console", "Hello From Console");
                        Console.WriteLine("Press Enter to close.");
                        Console.ReadLine();
                    }
            }
        }