async getClients()

in src/ConfigurationClientManager.ts [115:140]


    async getClients(): Promise<ConfigurationClientWrapper[]> {
        if (!this.#isFailoverable) {
            return this.#staticClients;
        }

        const currentTime = Date.now();
        // Filter static clients whose backoff time has ended
        let availableClients = this.#staticClients.filter(client => client.backoffEndTime <= currentTime);
        if (currentTime >= this.#lastFallbackClientRefreshAttempt + MINIMAL_CLIENT_REFRESH_INTERVAL &&
            (!this.#dynamicClients ||
            // All dynamic clients are in backoff means no client is available
            this.#dynamicClients.every(client => currentTime < client.backoffEndTime) ||
            currentTime >= this.#lastFallbackClientUpdateTime + FALLBACK_CLIENT_EXPIRE_INTERVAL)) {
            await this.#discoverFallbackClients(this.endpoint.hostname);
            return availableClients.concat(this.#dynamicClients);
        }

        // If there are dynamic clients, filter and concatenate them
        if (this.#dynamicClients && this.#dynamicClients.length > 0) {
            availableClients = availableClients.concat(
                this.#dynamicClients
                    .filter(client => client.backoffEndTime <= currentTime));
        }

        return availableClients;
    }