Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ProviderInstanceRegistryMutator.ts

27 lines1.2 KB

1/** Reconcile closes removed/replaced scopes before creating replacements: at most one live instance per id. */
2import type {
3 ProviderInstanceConfigMap,
4 ProviderInstanceId,
5 SecretReference,
6} from "@t3tools/contracts";
7import * as Context from "effect/Context";
8import type * as Effect from "effect/Effect";
9​
10export interface ProviderInstanceRegistryMutatorShape {
11 readonly reconcile: (configMap: ProviderInstanceConfigMap) => Effect.Effect<void>;
12 /** Re-reads the secrets of every instance, or one, and rebuilds those whose secrets changed. */
13 readonly reloadSecrets: (instanceId?: ProviderInstanceId) => Effect.Effect<void>;
14 /**
15 * Rebuilds the instances that read `reference` with `value`, keeping the other secrets a live
16 * instance holds, and returns them. A parked instance reads its other secrets from the resolver.
17 */
18 readonly applySecret: (
19 reference: SecretReference,
20 value: string,
21 ) => Effect.Effect<ReadonlyArray<ProviderInstanceId>>;
23​
24export class ProviderInstanceRegistryMutator extends Context.Service<
25 ProviderInstanceRegistryMutator,
26 ProviderInstanceRegistryMutatorShape
27>()("t3/provider/ProviderInstanceRegistryMutator") {}