UNPKG

1.38 kBPlain TextView Raw
1import {IncomingShuffleState} from './IncomingShuffleState';
2import {OutgoingShuffleState} from './OutgoingShuffleState';
3import {AsyncExecService, Logger} from 'cyclon.p2p-common';
4import {CyclonNode, CyclonNodePointer} from 'cyclon.p2p';
5
6export class ShuffleStateFactory{
7
8 constructor(private readonly logger: Logger,
9 private readonly asyncExecService: AsyncExecService) {
10 }
11
12 /**
13 * Create a new outgoing shuffle state
14 *
15 * @param localNode The local Cyclon node
16 * @param destinationNodePointer The pointer to the destination node
17 * @param shuffleSet The set of node pointers to send in the request
18 * @returns {OutgoingShuffleState}
19 */
20 createOutgoingShuffleState(localNode: CyclonNode, destinationNodePointer: CyclonNodePointer, shuffleSet: CyclonNodePointer[]) {
21 return new OutgoingShuffleState(localNode, destinationNodePointer, shuffleSet, this.asyncExecService, this.logger);
22 }
23
24 /**
25 * Create a new incoming shuffle state
26 *
27 * @param localNode The local Cyclon node
28 * @param sourcePointer The source peer's node pointer
29 * @returns {IncomingShuffleState}
30 */
31 createIncomingShuffleState(localNode: CyclonNode, sourcePointer: CyclonNodePointer) {
32 return new IncomingShuffleState(localNode, sourcePointer, this.asyncExecService, this.logger);
33 }
34}