Skip to content

Commit

Permalink
Fix stub to reuse actors proxy
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Candeia <[email protected]>
  • Loading branch information
mcandeia committed Dec 5, 2024
1 parent f7619dc commit ba67c8f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/actors/stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@ export interface ActorsOptions {
actorIdHeaderName?: string;
errorHandling?: Record<string, new (...args: any[]) => Error>;
}
const stub = <TInstance extends Actor>(
actor: ActorConstructor<TInstance> | string,
options?: ActorsOptions | undefined,
): { id: StubFactory<TInstance> } => {
const factory = (id: string, discriminator?: string) =>
createHttpInvoker(id, discriminator, options);
return create(actor, factory);
};

/**
* utilities to create and manage actors.
*/
export const actors = {
proxy: stub,
stub,
proxy: <TInstance extends Actor>(
actor: ActorConstructor<TInstance> | string,
options?: ActorsOptions | undefined,
): { id: StubFactory<TInstance> } => {
const factory = (id: string, discriminator?: string) =>
createHttpInvoker(id, discriminator, options);
return create(actor, factory);
},
stub: <TInstance extends Actor>(
actor: ActorConstructor<TInstance> | string,
options?: ActorsOptions | undefined,
): { id: StubFactory<TInstance> } => {
return actors.proxy(actor, options);
},
};

0 comments on commit ba67c8f

Please sign in to comment.