-
Notifications
You must be signed in to change notification settings - Fork 536
/
Copy pathlambdaFactory.ts
46 lines (41 loc) · 1.09 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
39
40
41
42
43
44
45
46
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/
import { EventEmitter } from "events";
import {
IContext,
IPublisher,
IPartitionLambda,
IPartitionLambdaFactory,
IServiceConfiguration,
IClientManager,
} from "@fluidframework/server-services-core";
import { BroadcasterLambda } from "./lambda";
/**
* @internal
*/
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: undefined, context: IContext): Promise<IPartitionLambda> {
return new BroadcasterLambda(
this.publisher,
context,
this.serviceConfiguration,
this.clientManager,
);
}
public async dispose(): Promise<void> {
await this.publisher.close();
}
}