This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createWorker( | |
id: string | null, | |
taskType: string, | |
taskHandler: ZB.ZBWorkerTaskHandler, | |
options?: ZBWorkerOptions & ZBClientOptions, | |
onConnectionError?: ZB.ConnectionErrorHandler | undefined): ZBWorker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const zbWorker = zbc.createWorker('demo-worker-1', 'demo-service', handler) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createWorker( | |
id: string, | |
taskType: string, | |
taskHandler: ZB.ZBWorkerTaskHandler, | |
options?: ZBWorkerOptions & ZBClientOptions, | |
onConnectionError?: ZB.ConnectionErrorHandler): ZBWorker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public createWorker( | |
id: string | null, | |
taskType: string, | |
taskHandler: ZB.ZBWorkerTaskHandler, | |
options: ZB.ZBWorkerOptions & ZB.ZBClientOptions = {} as any, | |
onConnectionError?: ZB.ConnectionErrorHandler | |
) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async deployWorkflow( | |
workflow: ZB.DeployWorkflowFiles | ZB.DeployWorkflowBuffer | |
): Promise<ZB.DeployWorkflowResponse> { | |
const deploy = (workflows: ZB.WorkflowRequestObject[]) => | |
this.executeOperation('deployWorkflow', () => | |
this.gRPCClient.deployWorkflowSync({ | |
workflows, | |
}) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const filereader = wf => typeof wf === 'object' ? wf : read(wf) | |
const read = filename => fs.existsSync(filename) ? | |
{ buffer: fs.readFileSync(filename) } : | |
{ error: filename } | |
const outcomes = workflows.map(filereader) | |
const { error, buffer } = outcomes.reduce((acc, o) => o.error ? | |
{ error: [...acc.error, o.error], buffer: acc.buffer } : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @param workflow - A path or array of paths to .bpmn files or an object describing the workflow | |
* @param {redeploy?: boolean} - Redeploy workflow. Defaults to true. | |
* If set false, will not redeploy a workflow that exists. | |
*/ | |
public async deployWorkflow( | |
workflow: string | string[] | { definition: Buffer; name: string } | |
): Promise<ZB.DeployWorkflowResponse> { | |
const workflows = Array.isArray(workflow) ? workflow : [workflow] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @param workflow - A path or array of paths to .bpmn files or an object describing the workflow | |
*/ | |
public async deployWorkflow( | |
workflow: ZB.DeployWorkflowFiles | ZB.DeployWorkflowBuffer | |
): Promise<ZB.DeployWorkflowResponse> { | |
const isBuffer = ( | |
wf: ZB.DeployWorkflowBuffer | ZB.DeployWorkflowFiles | |
): wf is ZB.DeployWorkflowBuffer => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const GRPCConnection = gRPC => url => { | |
let connected = false | |
const _connection = gRPC(url) | |
_connection.on('connect', () => (connected = true)) | |
_connection.on('disconnect', () => (connected = false)) | |
return { | |
getIsConnected(): connected, | |
connect: () => connected || _connection.connect() | |
send: command => _connection.send(command) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const GRPCConnection = url => { | |
let connected = false | |
const _connection = gRPC(url) | |
_connection.on('connect', () => (connected = true)) | |
_connection.on('disconnect', () => (connected = false)) | |
return { | |
getIsConnected(): connected, | |
connect: () => connected || _connection.connect() | |
send: command => _connection.send(command) | |
} |