Esempio n. 1
0
        public void Start()
        {
            var connectionSettings = ConnectionSettings.Create()
                                     .UseCustomLogger(new EventStoreLog4Net())
                                     .KeepReconnecting();

            if (!string.IsNullOrEmpty(EventStoreGossipSeedEndpoints))
            {
                var clusterSettings = ClusterSettings.Create()
                                      .DiscoverClusterViaGossipSeeds()
                                      .SetGossipSeedEndPoints(EventStoreGossipSeedEndpoints.Split(',').Select(x =>
                {
                    var parts = x.Split(':');
                    return(new IPEndPoint(IPAddress.Parse(parts[0]), Convert.ToInt32(parts[1])));
                }).ToArray());
                _eventStoreConnection = EventStoreConnection.Create(connectionSettings, clusterSettings);
            }
            else
            {
                _eventStoreConnection = EventStoreConnection.Create(connectionSettings, new Uri(EventStoreUri));
            }
            _eventStoreConnection.ConnectAsync().Wait();

            GrpcEnvironment.SetLogger(new GrpcLog4Net("GRPC"));
            _server = new Grpc.Core.Server
            {
                Services = { EventStore.BindService(new EventStoreImpl(_eventStoreConnection)) },
                Ports    = { new ServerPort(RpcHost, Convert.ToInt32(RpcPort), ServerCredentials.Insecure) }
            };

            _server.Start();
        }