forked from microsoft/FluidFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lambdaFactory.ts
38 lines (33 loc) · 1.19 KB
/
lambdaFactory.ts
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
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/
import { EventEmitter } from "events";
import {
IContext,
IPublisher,
IPartitionLambda,
IPartitionLambdaConfig,
IPartitionLambdaFactory,
IServiceConfiguration,
IClientManager,
} from "@fluidframework/server-services-core";
import { BroadcasterLambda } from "./lambda";
export class BroadcasterLambdaFactory extends EventEmitter implements IPartitionLambdaFactory {
constructor(
private readonly publisher: IPublisher,
private readonly serviceConfiguration: IServiceConfiguration,
private readonly clientManager: IClientManager | undefined) {
super();
this.publisher.on("error", (error) => {
// After an IO error we need to recreate the lambda
this.emit("error", error);
});
}
public async create(config: IPartitionLambdaConfig, context: IContext): Promise<IPartitionLambda> {
return new BroadcasterLambda(this.publisher, context, this.serviceConfiguration, this.clientManager);
}
public async dispose(): Promise<void> {
await this.publisher.close();
}
}