UNPKG

@dolittle/sdk.projections

Version:

Dolittle is a decentralized, distributed, event-driven microservice platform built to harness the power of events.

47 lines 3.76 kB
"use strict"; // Copyright (c) Dolittle. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. Object.defineProperty(exports, "__esModule", { value: true }); exports.Projections = void 0; const operators_1 = require("rxjs/operators"); const sdk_resilience_1 = require("@dolittle/sdk.resilience"); const IProjections_1 = require("./IProjections"); /** * Represents an implementation of {IProjections}. */ class Projections extends IProjections_1.IProjections { /** * Initializes an instance of {@link Projections}. * @param {ProjectionsClient} _client - The projections client to use. * @param {ExecutionContext} _executionContext - The base execution context of the client. * @param {ITenantServiceProviders} _services - For resolving services while handling requests. * @param {ITrackProcessors} _tracker - The tracker to register the started processors with. * @param {Logger} _logger - For logging. * @param {number} _pingInterval - The ping interval to configure the reverse call client with. */ constructor(_client, _executionContext, _services, _tracker, _logger, _pingInterval) { super(); this._client = _client; this._executionContext = _executionContext; this._services = _services; this._tracker = _tracker; this._logger = _logger; this._pingInterval = _pingInterval; } /** @inheritdoc */ register(projectionProcessor, cancellation = sdk_resilience_1.Cancellation.default) { this._tracker.registerProcessor(projectionProcessor.registerForeverWithPolicy((0, sdk_resilience_1.retryPipe)((0, operators_1.delay)(1000)), this._client, this._executionContext, this._services, this._logger, this._pingInterval, cancellation) .subscribe({ error: (error) => { if (error instanceof sdk_resilience_1.RetryCancelled) return; this._logger.error(`Failed to register projection: ${error}`); }, complete: () => { this._logger.error(`Projection registration completed.`); } })); } } exports.Projections = Projections; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUHJvamVjdGlvbnMuanMiLCJzb3VyY2VSb290IjoiLi4vIiwic291cmNlcyI6WyJQcm9qZWN0aW9ucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsK0NBQStDO0FBQy9DLHFHQUFxRzs7O0FBR3JHLDhDQUF1QztBQUl2Qyw2REFBbUY7QUFNbkYsaURB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