public PublishSubscribeServerRouter( ILoggerFactory loggerFactory, Func <Subscription, ITopicFilter> topicFilterFactory) { _topicFilterFactory = topicFilterFactory; _logger = loggerFactory.CreateLogger <PublishSubscribeServerRouter>(); _lookup = new SubscriptionWriterLookupCache <IServerStreamWriter <Message> >( new SubscriptionWriterLookup <IServerStreamWriter <Message> >()); }
public PublishSubscribeRouterActor( string clusterName, ILoggerFactory loggerFactory, Func <Subscription, ITopicFilter> topicFilterFactory, int sendBufferSize = 8192) { if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } _topicFilterFactory = topicFilterFactory ?? throw new ArgumentNullException(nameof(topicFilterFactory)); _lookup = new SubscriptionWriterLookupCache <PID>(new SubscriptionWriterLookup <PID>()); _logger = loggerFactory.CreateLogger <PublishSubscribeRouterActor>(); _publishSubscribeRouterActorName = $"{clusterName}_{typeof(PublishSubscribeRouterActor).FullName}"; Props props = Actor.FromFunc(ReceiveAsync).WithMailbox(() => BoundedMailbox.Create(sendBufferSize)); PubSubRouterActorPid = Actor.SpawnNamed(props, _publishSubscribeRouterActorName); _topologySubscription = Actor.EventStream .Subscribe <ClusterTopologyEvent>(clusterTopologyEvent => { PubSubRouterActorPid.Tell(clusterTopologyEvent); }); }