Skip to content

Instantly share code, notes, and snippets.

View jwulf's full-sized avatar
:octocat:
Coding on Halmak

Josh Wulf jwulf

:octocat:
Coding on Halmak
View GitHub Profile
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)
const grpcClient = new GrpcClient(config)
new GrpcMiddleware({ profile, grpcClient })
return new GrpcClient(config)
export class GrpcMiddleware {
private static autodetect(config: GrpcClientCtor): GrpcConnectionProfile {
const isCamundaCloud = config.host.includes('zeebe.camunda.io')
return isCamundaCloud ? 'CAMUNDA_CLOUD' : 'VANILLA'
}
private characteristics: Characteristics
constructor(config: GrpcClientCtor) {
const profile = GrpcMiddleware.autodetect(config)
this.characteristics = ConnectionCharacteristics[profile]
}
type GrpcConnectionProfile = 'CAMUNDA_CLOUD' | 'VANILLA'
type Characteristics = any
const ConnectionCharacteristics: {
[key in GrpcConnectionProfile]: Characteristics
} = {
CAMUNDA_CLOUD: {},
VANILLA: {},
}
import { GrpcClient, GrpcClientCtor } from './GRPCClient'
export class GrpcConnectionFactory {
public static getGrpcClient(config: GrpcClientCtor) {
return new GrpcClient(config)
}
}
@jwulf
jwulf / cawemo.html
Created February 29, 2020 15:19
A Hugo shortcode to embed BPMN diagrams from Cawemo.com
<iframe
src="https://cawemo.com/embed/{{.Get 0}}"
style="width:700px;height:500px;border:1px solid #ccc"
allowfullscreen
></iframe>
<!-- Put this in layouts/shortcodes/cawemo.html
To use it in hugo, get an Embed link for your diagram on cawemo.com,
then use it like this your post:
export function decodeCreateZBWorkerSig(config) {
const isShorthandSig = typeof config.taskTypeOrTaskHandler === 'function'
const taskHandler: ZB.ZBWorkerTaskHandler = isShorthandSig
? (config.taskTypeOrTaskHandler as ZB.ZBWorkerTaskHandler)
: (config.taskHandlerOrOptions as ZB.ZBWorkerTaskHandler)
const id: string | null = isShorthandSig
? (config.idOrTaskType as string)
: null
const taskType: string = isShorthandSig
? (config.idOrTaskType as string)
const config = decodeCreateZBWorkerSig({
idOrTaskType,
onConnectionError,
optionsOrOnConnectionError,
taskHandlerOrOptions,
taskTypeOrTaskHandler,
})
const zbWorker = zbc.createWorker('demo-service', handler)
public createWorker(
id: string | null,
taskType: string,
taskHandler: ZB.ZBWorkerTaskHandler,
options?: ZB.ZBWorkerOptions & ZB.ZBClientOptions,
onConnectionError?: ZB.ConnectionErrorHandler | undefined
): ZBWorker
public createWorker(
taskType: string,
taskHandler: ZB.ZBWorkerTaskHandler,
const zbWorker = zbc.createWorker(null, 'demo-service', handler)