Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
acn-ericlaw committed Dec 21, 2024
1 parent f9dc7ec commit 642923a
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/models/composable.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/models/composable.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dist/resources/templates/preload.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import fs from 'fs';
import { fileURLToPath } from "url";
import { Logger, AppConfig, FunctionRegistry, Platform } from 'mercury';
// import the user functions
// import composable functions
${import-statements}

const log = Logger.getInstance();
Expand Down Expand Up @@ -39,9 +39,9 @@ export class ComposableLoader {
// initialize base configuration
const config = AppConfig.getInstance(resourcePath);
log.info(`Base configuration ${config.getId()}`);
// load composable functions
// initialize composable functions
${service-list}
// register them into the event system
// register the functions into the event system
const platform = Platform.getInstance();
const registry = new FunctionRegistry();
const registered = registry.getFunctions();
Expand Down
13 changes: 12 additions & 1 deletion dist/util/function-registry.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@ import { EventEnvelope } from '../models/event-envelope.js';
export declare class FunctionRegistry {
constructor();
/**
* Save a Composable class to the registry by name.
* Save a Composable function to the registry by name.
*
* @param that is the class instance of the Composable function
* @param instances for concurrency
* @param isPublic is true if function is visible thru event-over-http
* @param isInterceptor is true if function is an event interceptor
*/
saveFunction(that: object, instances: number, isPublic: boolean, isInterceptor: boolean): void;
/**
* Remove a composable function from the registry by name.
*
* @param name of the function
*/
removeFunction(name: string): void;
/**
* Retrieve metadata for the composable function
*
* @param name of the function
* @returns map of key-values
*/
getMetadata(name: string): object;
/**
* Retrieve a function by name so that you can register it programmatically.
Expand Down
13 changes: 12 additions & 1 deletion dist/util/function-registry.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/util/function-registry.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/po.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('post office use cases', () => {
const appConfig = AppConfig.getInstance(resourcePath).getReader();
// save the helloWorld as DEMO_LIBRARY_FUNCTION so that it can be retrieved by name
const helloWorld = new HelloWorld();
registry.saveFunction(helloWorld);
registry.saveFunction(helloWorld, 1, false, false);
platform = Platform.getInstance();
// register a hello.world function to echo the incoming payload
platform.register(HELLO_WORLD_SERVICE, helloWorld.handleEvent, false, HELLO_WORLD_INSTANCES);
Expand Down

0 comments on commit 642923a

Please sign in to comment.