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
// Production steps of ECMA-262, Edition 5, 15.4.4.19 | |
// Reference: http://es5.github.io/#x15.4.4.19 | |
if (!Array.prototype.map) { | |
Array.prototype.map = function(callback/*, thisArg*/) { | |
var T, A, k; | |
if (this == null) { | |
throw new TypeError('this is null or not defined'); | |
} | |
var O = Object(this); |
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
var content = info.data; | |
var project_arr = []; | |
var identity = {}; | |
for (var i = 0; i < content.length; i++) { | |
if (content.length > 0) { | |
identity.Project_ID = content[i].id; | |
identity.Project_Name = content[i].name; | |
identity.Project_Start_Date = content[i].starts_at; | |
identity.Project_End_Date = content[i].ends_at; | |
identity.Project_Status = content[i].project_state; |
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
export const JobBuffer = ({ | |
handler, | |
timeout, | |
batchSize, | |
worker, | |
}: { | |
handler: ZBBatchWorkerTaskHandler<any, any, any> | |
timeout: number | |
batchSize: number | |
worker: ZBBatchWorker<any, any, any> |
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
import { ZBClient } from 'zeebe-node' | |
const zbc = new ZBClient() | |
const batchWorker = zbc.createZBBatchWorker({ | |
taskType: 'rate-limited-api-call', | |
jobBatchMinSize: 10, | |
jobBatchMaxTime: 60, | |
timeout: 80, | |
taskHandler: (jobs, worker) => { |
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
import { ZBClient } from 'zeebe-node' | |
const zbc = new ZBClient() | |
const batchWorker = zbc.createZBBatchWorker({ | |
taskType: 'rate-limited-api-call', | |
taskHandler: myHandler, | |
jobBatchMinSize: 10, // first of: every 10 jobs | |
jobBatchMaxTime: 60, // or every 60 seconds | |
timeout: 80 // must be greater than jobBatchMaxTime |
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
private createInterceptedGrpcClient(config: GrpcClientCtor) { | |
const grpcClient = new GrpcClient(config) | |
grpcClient.on(MiddlewareSignals.Log.Debug, this.debug) | |
grpcClient.on(MiddlewareSignals.Log.Info, this.info) | |
grpcClient.on(MiddlewareSignals.Log.Error, this.error) | |
grpcClient.on(MiddlewareSignals.Event.Error, this.emitError) | |
grpcClient.on(MiddlewareSignals.Event.Ready, this.emitReady) | |
return grpcClient | |
} | |
private info = (msg: any) => this.log.info(msg) |
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
private handleGrpcError = (stream: any) => async (err: any) => { | |
// this.emit('error', err) | |
this.emit(MiddlewareSignals.Event.Error, err) | |
// this.logger.error(`GRPC ERROR: ${err.message}`) | |
this.emit(MiddlewareSignals.Log.Error, `GRPC ERROR: ${err.message}`) | |
const channelState = await this.watchGrpcChannel() | |
// this.logger.debug( | |
// `gRPC Channel state: ${connectivityState[channelState]}` | |
// ) | |
this.emit( |
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
export const MiddlewareSignals = { | |
Log: { | |
Error: 'MIDDLEWARE_ERROR', | |
Info: 'MIDDLEWARE_INFO', | |
Debug: 'MIDDLEWARE_DEBUG' | |
}, | |
Event: { | |
Error: 'error', | |
Ready: 'ready', | |
}, |
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
export class GrpcMiddleware { | |
private grpcClient: GrpcClient | |
private characteristics: Characteristics | |
private log: ZBLogger | |
constructor({ | |
profile, | |
config, | |
}: { | |
profile: GrpcConnectionProfile | |
config: GrpcClientCtor |
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
export class GrpcConnectionFactory { | |
private static autodetect(config: GrpcClientCtor): GrpcConnectionProfile { | |
const isCamundaCloud = config.host.includes('zeebe.camunda.io') | |
return isCamundaCloud ? 'CAMUNDA_CLOUD' : 'VANILLA' | |
} | |
public static getGrpcClient(config: GrpcClientCtor) { | |
const profile = GrpcConnectionFactory.autodetect(config) | |
return new GrpcMiddleware({ profile, config }).getGrpcClient() | |
} | |
} |