-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathlayer.ts
More file actions
44 lines (36 loc) · 1.65 KB
/
Copy pathlayer.ts
File metadata and controls
44 lines (36 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as Stream from "effect/Stream";
import * as ConnectionResolver from "./resolver.ts";
import * as ConnectionDriver from "./driver.ts";
import * as EnvironmentRegistry from "./registry.ts";
import * as ConnectionOnboarding from "./onboarding.ts";
import * as PlatformConnectionSource from "../platform/source.ts";
import * as RelayEnvironmentDiscovery from "../relay/discovery.ts";
import * as RemoteEnvironmentAuthorization from "../authorization/service.ts";
import * as RpcSession from "../rpc/session.ts";
const resolverLayer = ConnectionResolver.layer.pipe(
Layer.provide(RemoteEnvironmentAuthorization.layer),
);
const driverLayer = ConnectionDriver.layer.pipe(
Layer.provide(Layer.mergeAll(resolverLayer, RpcSession.layer)),
);
const registryLayer = EnvironmentRegistry.layer.pipe(Layer.provide(driverLayer));
const onboardingLayer = ConnectionOnboarding.layer.pipe(Layer.provide(registryLayer));
const connectionServicesLayer = Layer.mergeAll(
registryLayer,
RelayEnvironmentDiscovery.layer,
onboardingLayer,
);
const connectionStartupLayer = Layer.effectDiscard(
Effect.gen(function* () {
const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
const platformSource = yield* PlatformConnectionSource.PlatformConnectionSource;
yield* registry.start;
yield* platformSource.registrations.pipe(
Stream.runForEach(registry.reconcilePlatform),
Effect.forkScoped,
);
}).pipe(Effect.withSpan("clientRuntime.connection.application.start")),
);
export const layer = connectionStartupLayer.pipe(Layer.provideMerge(connectionServicesLayer));