コード例 #1
0
    /**
     * Catch-up subscription for one stream.
     * 
     * @constructor
     * @param {Connection} connection The connection to Event Store
     * @param {string} streamId The stream name (only if subscribing to a single stream)
     * @param {number} fromEventNumberExclusive Which event number to start after (if null, then from the beginning of the stream.)
     * @param {ICredentials} userCredentials User credentials for the operations.
     * @param {function} eventAppeared Callback for each event received
     * @param {function} liveProcessingStarted Callback when read history phase finishes.
     * @param {function} subscriptionDropped Callback when subscription drops or is dropped.
     * @param {CatchUpSubscriptionSettings} settings Settings for this subscription.
     */
    function EventStoreStreamCatchUpSubscription(connection, streamId, fromEventNumberExclusive, userCredentials, eventAppeared, liveProcessingStarted, subscriptionDropped, settings) {
        // Base class constructor (JS-style).
        EventStoreCatchUpSubscription.call(this, connection, streamId, userCredentials, eventAppeared, liveProcessingStarted, subscriptionDropped, settings);

        ArgValidator.notNull(streamId, 'streamId');

        this._lastProcessedEventNumber = ArgValidator.isNumber(fromEventNumberExclusive) ? fromEventNumberExclusive : -1;
        this._nextReadEventNumber = ArgValidator.isNumber(fromEventNumberExclusive) ? fromEventNumberExclusive : 0;
    }
コード例 #2
0
    /**
     * Base class representing catch-up subscriptions.
     * 
     * @constructor
     * @param {Connection} connection The connection to Event Store
     * @param {string} streamId The stream name (only if subscribing to a single stream)
     * @param {ICredentials} userCredentials User credentials for the operations.
     * @param {function} eventAppeared Callback for each event received
     * @param {function} liveProcessingStarted Callback when read history phase finishes.
     * @param {function} subscriptionDropped Callback when subscription drops or is dropped.
     * @param {CatchUpSubscriptionSettings} settings Settings for this subscription.
     */
    function EventStoreCatchUpSubscription(connection, streamId, userCredentials, eventAppeared, liveProcessingStarted, subscriptionDropped, settings) {
        ArgValidator.notNull(connection, 'connection');
        ArgValidator.notNull(eventAppeared, 'eventAppeared');
        if (!settings) settings = new CatchUpSubscriptionSettings();

        this._connection = connection;
        this._streamId = streamId || "";
        this._resolveLinkTos = settings.resolveLinkTos;
        this._userCredentials = userCredentials;
        this.readBatchSize = settings.readBatchSize;
        this.maxPushQueueSize = settings.maxLiveQueueSize;
        this.eventAppeared = eventAppeared;
        this._liveProcessingStarted = liveProcessingStarted;
        this._subscriptionDropped = subscriptionDropped;
        this.debug = settings.debug;
        this._shouldStop = false;
        this._dropData = null;
        this._liveQueue = [];
        this._allowProcessing = false;
        this._subscription = null;
    }