All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.src.topic-client.js Maven / Gradle / Ivy

The newest version!
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TopicClient = void 0;
const AbstractTopicClient_1 = require("@gomomento/sdk-core/dist/src/internal/clients/pubsub/AbstractTopicClient");
const _1 = require(".");
const pubsub_client_1 = require("./internal/pubsub-client");
const webhook_client_1 = require("./internal/webhook-client");
const utils_1 = require("@gomomento/sdk-core/dist/src/internal/utils");
const sdk_core_1 = require("@gomomento/sdk-core");
/**
 * Momento Topic Client.
 *
 * Publish and subscribe to topics.
 */
class TopicClient extends AbstractTopicClient_1.AbstractTopicClient {
    /**
     * Creates an instance of TopicClient.
     */
    constructor(props) {
        var _a, _b;
        const allProps = {
            credentialProvider: (_a = props === null || props === void 0 ? void 0 : props.credentialProvider) !== null && _a !== void 0 ? _a : (0, sdk_core_1.getDefaultCredentialProvider)(),
            configuration: (_b = props === null || props === void 0 ? void 0 : props.configuration) !== null && _b !== void 0 ? _b : getDefaultTopicClientConfiguration(),
        };
        const numClients = allProps.configuration
            .getTransportStrategy()
            .getGrpcConfig()
            .getNumClients();
        super(allProps.configuration.getLoggerFactory().getLogger(TopicClient.name), (0, utils_1.range)(numClients).map(_ => new pubsub_client_1.PubsubClient(allProps)), new webhook_client_1.WebhookClient(allProps));
        this.logger.debug('Instantiated Momento TopicClient');
    }
}
exports.TopicClient = TopicClient;
function getDefaultTopicClientConfiguration() {
    const config = _1.TopicConfigurations.Default.latest();
    const logger = config.getLoggerFactory().getLogger('TopicClient');
    logger.info('No configuration provided to TopicClient. Using latest "Default" configuration, suitable for development. For production use, consider specifying an explicit configuration.');
    return config;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9waWMtY2xpZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3RvcGljLWNsaWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBp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