예제 #1
0
        public EventStoreEmbeddedNodeConnection(ConnectionSettings settings, string connectionName, IPublisher publisher, ISubscriber bus, IAuthenticationProvider authenticationProvider)
        {
            Ensure.NotNull(publisher, "publisher");
            Ensure.NotNull(settings, "settings");

            Guid connectionId = Guid.NewGuid();

            _settings               = settings;
            _connectionName         = connectionName;
            _publisher              = publisher;
            _authenticationProvider = authenticationProvider;
            _subscriptionBus        = new InMemoryBus("Embedded Client Subscriptions");
            _subscriptions          = new EmbeddedSubscriber(_subscriptionBus, _authenticationProvider, _settings.Log, connectionId);

            _subscriptionBus.Subscribe <ClientMessage.SubscriptionConfirmation>(_subscriptions);
            _subscriptionBus.Subscribe <ClientMessage.SubscriptionDropped>(_subscriptions);
            _subscriptionBus.Subscribe <ClientMessage.StreamEventAppeared>(_subscriptions);
            _subscriptionBus.Subscribe <ClientMessage.PersistentSubscriptionConfirmation>(_subscriptions);
            _subscriptionBus.Subscribe <ClientMessage.PersistentSubscriptionStreamEventAppeared>(_subscriptions);
            _subscriptionBus.Subscribe(new AdHocHandler <ClientMessage.SubscribeToStream>(_publisher.Publish));
            _subscriptionBus.Subscribe(new AdHocHandler <ClientMessage.UnsubscribeFromStream>(_publisher.Publish));
            _subscriptionBus.Subscribe(new AdHocHandler <ClientMessage.ConnectToPersistentSubscription>(_publisher.Publish));
            _subscriptionBus.Subscribe(new AdHocHandler <ClientMessage.PersistentSubscriptionAckEvents>(_publisher.Publish));
            _subscriptionBus.Subscribe(new AdHocHandler <ClientMessage.PersistentSubscriptionNackEvents>(_publisher.Publish));

            bus.Subscribe(new AdHocHandler <SystemMessage.BecomeShutdown>(_ => Disconnected(this, new ClientConnectionEventArgs(this, new IPEndPoint(IPAddress.None, 0)))));
        }
예제 #2
0
 internal EmbeddedEventStorePersistentSubscription(
     string subscriptionId, string streamId,
     Func <EventStorePersistentSubscriptionBase, ResolvedEvent, Task> eventAppeared,
     Action <EventStorePersistentSubscriptionBase, SubscriptionDropReason, Exception> subscriptionDropped,
     UserCredentials userCredentials, ILogger log, bool verboseLogging, ConnectionSettings settings,
     EmbeddedSubscriber subscriptions,
     int bufferSize = 10, bool autoAck = true)
     : base(
         subscriptionId, streamId, eventAppeared, subscriptionDropped, userCredentials, log, verboseLogging,
         settings, bufferSize, autoAck)
 {
     _subscriptions = subscriptions;
 }