ibm-appconfiguration-js-client-sdk
Version:
IBM Cloud App Configuration JavaScript Client SDK
47 lines (46 loc) • 1.82 kB
TypeScript
/**
* Copyright 2022 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import BTree from 'sorted-btree';
export interface RolloutPhase {
percentage: number;
duration: number | null;
duration_type: string | null;
}
export interface RolloutConfiguration {
start_at: string;
phases: RolloutPhase[];
}
export declare class PhaseScheduler {
static timestamps: number[];
static timerId: ReturnType<typeof setTimeout> | null;
static onPhaseCallback: () => void;
private constructor();
static addTimestamp(timestamp: number): void;
private static scheduleNext;
static reset(): void;
}
/**
* Parses progressive rollout phases into a B-Tree for efficient timestamp-to-percentage lookups
* @param configuration - The rollout configuration object
* @returns BTree mapping timestamp (ms) to percentage, or null on error
*/
export declare function parseRolloutConfigurationPhases(configuration: RolloutConfiguration | null | undefined): BTree<number, number> | null;
/**
* Returns the current rollout percentage based on current time
* @param rolloutMap - BTree mapping timestamp to percentage
* @returns Current rollout percentage
*/
export declare function getCurrentRolloutPercentage(rolloutMap: BTree<number, number> | null): number;