Пример #1
0
        /// <summary>
        /// Optional override to create listeners (like tcp, http) for this service instance.
        /// </summary>
        /// <returns>The collection of listeners.</returns>
        protected override IEnumerable <ServiceInstanceListener> CreateServiceInstanceListeners()
        {
            return(new[]
            {
                new ServiceInstanceListener(serviceContext =>
                                            new KestrelCommunicationListener(serviceContext, "ApiEndpoint", (url, listener) =>
                {
                    ServiceEventSource.Current.ServiceMessage(serviceContext, $"Starting Kestrel on {url}");

                    return new WebHostBuilder()
                    .UseKestrel()
                    .ConfigureServices(
                        services => services
                        .AddSingleton(serviceContext)
                        .AddSingleton <IBrokerClient>(new BrokerClient(FabricConfiguration.GetBrokerServiceLocator()))
                        )
                    .UseContentRoot(Directory.GetCurrentDirectory())
                    .UseStartup <Startup>()
                    .UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.None)
                    .UseUrls(url)
                    .Build();
                }))
            });
        }
 public SampleActorSubscriber(ActorService actorService, ActorId actorId)
     : base(actorService, actorId)
 {
     _brokerClient = new BrokerClient(FabricConfiguration.GetBrokerServiceLocator());
 }