@outputai/core 0.1.3-dev.0 → 0.1.4-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/consts.js +2 -0
- package/src/hooks/index.d.ts +8 -0
- package/src/hooks/index.js +2 -0
- package/src/worker/index.js +2 -0
package/package.json
CHANGED
package/src/consts.js
CHANGED
package/src/hooks/index.d.ts
CHANGED
|
@@ -19,6 +19,14 @@ export interface ErrorHookPayload {
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function onError( handler: ( payload: ErrorHookPayload ) => void ): void;
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Register a handler to be invoked once, before the worker starts processing tasks.
|
|
24
|
+
* Runs synchronously after activities are loaded and before Worker.create().
|
|
25
|
+
*
|
|
26
|
+
* @param handler - Function called with no arguments.
|
|
27
|
+
*/
|
|
28
|
+
export declare function onBeforeStart( handler: () => void ): void;
|
|
29
|
+
|
|
22
30
|
/**
|
|
23
31
|
* Register a handler to be invoked when a given event happens
|
|
24
32
|
*
|
package/src/hooks/index.js
CHANGED
|
@@ -21,6 +21,8 @@ export const onError = handler => {
|
|
|
21
21
|
invokeHandler( { source: 'runtime', error } ) );
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
export const onBeforeStart = handler => messageBus.on( BusEventType.WORKER_BEFORE_START, handler );
|
|
25
|
+
|
|
24
26
|
export const on = ( eventName, handler ) => {
|
|
25
27
|
messageBus.on( `external:${eventName}`, async payload => {
|
|
26
28
|
try {
|
package/src/worker/index.js
CHANGED
|
@@ -40,6 +40,8 @@ const callerDir = process.argv[2];
|
|
|
40
40
|
log.info( 'Loading activities...', { callerDir } );
|
|
41
41
|
const activities = await loadActivities( callerDir, workflows );
|
|
42
42
|
|
|
43
|
+
messageBus.emit( BusEventType.WORKER_BEFORE_START );
|
|
44
|
+
|
|
43
45
|
log.info( 'Creating worker entry point...' );
|
|
44
46
|
const workflowsPath = createWorkflowsEntryPoint( workflows );
|
|
45
47
|
|