Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/gitpod-protocol/src/experiments/always-default.ts
2500 views
1
/**
2
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
import { Attributes, Client } from "./types";
7
8
// AlwaysReturningDefaultValueClient is an implemention of an experiments.Client which performs no lookup/network operation
9
// and always returns the default value for a given experimentName.
10
// This client is used for non-SaaS version of Gitpod, in particular for self-hosted installations where external
11
// network connections are not desirable or even possible.
12
class AlwaysReturningDefaultValueClient implements Client {
13
getValueAsync<T>(experimentName: string, defaultValue: T, attributes: Attributes): Promise<T> {
14
return Promise.resolve(defaultValue);
15
}
16
17
dispose(): void {
18
// there is nothing to dispose, no-op.
19
}
20
}
21
22
export function newAlwaysReturningDefaultValueClient(): Client {
23
return new AlwaysReturningDefaultValueClient();
24
}
25
26