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

package.dist.src.preview-leaderboard-client.js Maven / Gradle / Ivy

The newest version!
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PreviewLeaderboardClient = void 0;
const sdk_core_1 = require("@gomomento/sdk-core");
const leaderboard_data_client_1 = require("./internal/leaderboard-data-client");
const leaderboard_1 = require("./internal/leaderboard");
const index_1 = require("./index");
/**
 * PREVIEW Momento Leaderboard Client
 * WARNING: the API for this client is not yet stable and may change without notice.
 * Please contact Momento if you would like to try this preview.
 *
 * Leaderboard methods return a response object unique to each request.
 * The response object is resolved to a type-safe object of one of several
 * sub-types. See the documentation for each response type for details.
 */
class PreviewLeaderboardClient {
    constructor(props) {
        var _a, _b;
        const configuration = (_a = props.configuration) !== null && _a !== void 0 ? _a : getDefaultLeaderboardConfiguration();
        const allProps = {
            configuration: configuration,
            credentialProvider: (_b = props.credentialProvider) !== null && _b !== void 0 ? _b : (0, sdk_core_1.getDefaultCredentialProvider)(),
        };
        this.configuration = configuration;
        this.logger = configuration.getLoggerFactory().getLogger(this);
        this.logger.debug('Creating Momento LeaderboardClient');
        this.dataClient = new leaderboard_data_client_1.LeaderboardDataClient(allProps, '0'); // only creating one leaderboard client
        // Initialize middlewares that have init methods. These currently start
        // background tasks for logging that will execute until they are explicitly
        // stopped. This is usually handled by the client's close method, but if
        // there is ever a chance that this client constructor may fail after these
        // methods are called, it is up to you to catch the exception and call close
        // on each of these manually.
        this.configuration.getMiddlewares().forEach(m => {
            if (m.init) {
                m.init();
            }
        });
    }
    close() {
        this.dataClient.close();
        this.configuration.getMiddlewares().forEach(m => {
            if (m.close) {
                m.close();
            }
        });
    }
    /**
     * Creates an instance of LeaderboardClient with floating point scores up until 53 bits of precision.
     */
    leaderboard(cacheName, leaderboardName) {
        return new leaderboard_1.Leaderboard(this.dataClient, cacheName, leaderboardName);
    }
}
exports.PreviewLeaderboardClient = PreviewLeaderboardClient;
function getDefaultLeaderboardConfiguration() {
    return index_1.Le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