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