Skip to content

Commit 133cc05

Browse files
geroplroboquat
authored andcommitted
[server] Make ConfigCatClientFactory injectable
1 parent 005d49c commit 133cc05

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

components/gitpod-protocol/src/experiments/configcat-server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { newAlwaysReturningDefaultValueClient } from "./always-default";
1212

1313
let client: Client | undefined;
1414

15+
export type ConfigCatClientFactory = () => Client;
16+
export const ConfigCatClientFactory = Symbol("ConfigCatClientFactory");
17+
1518
export function getExperimentsClientForBackend(): Client {
1619
// We have already instantiated a client, we can just re-use it.
1720
if (client !== undefined) {

components/server/src/container-module.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ import {
107107
UsageServiceClientProvider,
108108
} from "@gitpod/usage-api/lib/usage/v1/sugar";
109109
import { CommunityEntitlementService, EntitlementService } from "./billing/entitlement-service";
110+
import {
111+
ConfigCatClientFactory,
112+
getExperimentsClientForBackend,
113+
} from "@gitpod/gitpod-protocol/lib/experiments/configcat-server";
110114

111115
export const productionContainerModule = new ContainerModule((bind, unbind, isBound, rebind) => {
112116
bind(Config).toConstantValue(ConfigFile.fromFile());
@@ -264,4 +268,10 @@ export const productionContainerModule = new ContainerModule((bind, unbind, isBo
264268
bind(UsageServiceClientCallMetrics).toService(IClientCallMetrics);
265269

266270
bind(EntitlementService).to(CommunityEntitlementService).inSingletonScope();
271+
272+
bind(ConfigCatClientFactory)
273+
.toDynamicValue((ctx) => {
274+
return () => getExperimentsClientForBackend();
275+
})
276+
.inSingletonScope();
267277
});

0 commit comments

Comments
 (0)