Skip to content
This repository was archived by the owner on Apr 8, 2024. It is now read-only.

Commit d2a438f

Browse files
authored
Camunda cloud oauth (#68)
Camunda cloud oauth
2 parents 49333d1 + 3b6f83f commit d2a438f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2368
-1541
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
test:
3434
docker:
3535
- image: circleci/node:11.10.1
36-
- image: camunda/zeebe:0.20.0
36+
- image: camunda/zeebe:SNAPSHOT
3737
working_directory: ~/zeebe-client-node-js
3838
steps:
3939
- checkout

.vscode/settings.json

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
{
2-
"workbench.colorCustomizations": {
3-
"activityBar.background": "#0B3330",
4-
"titleBar.activeBackground": "#0F4844",
5-
"titleBar.activeForeground": "#F4FDFC"
6-
},
72
"editor.codeActionsOnSave": {
83
"source.organizeImports": true
9-
}
4+
},
5+
"workbench.colorCustomizations": {
6+
"activityBar.background": "#8a2ca2",
7+
"activityBar.foreground": "#e7e7e7",
8+
"activityBar.inactiveForeground": "#e7e7e799",
9+
"activityBarBadge.background": "#af9530",
10+
"activityBarBadge.foreground": "#15202b",
11+
"titleBar.activeBackground": "#68217a",
12+
"titleBar.inactiveBackground": "#68217a99",
13+
"titleBar.activeForeground": "#e7e7e7",
14+
"titleBar.inactiveForeground": "#e7e7e799",
15+
"statusBar.background": "#68217a",
16+
"statusBarItem.hoverBackground": "#8a2ca2",
17+
"statusBar.foreground": "#e7e7e7"
18+
},
19+
"peacock.color": "#68217A"
1020
}

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
# Version v0.21
2+
3+
• Add long polling support. See [#64](https://github.com/creditsenseau/zeebe-client-node-js/issues/64).
4+
@TODO: Add authentication via JWT.
5+
6+
# Version v0.20
7+
8+
• Add TLS support (Thanks Colin from the Camunda Cloud Team!).
9+
• Remove node-grpc-client dependency.
10+
• Change versioning to match Broker versioning (Thanks Tim!).
11+
112
# Version 2.4.0
213

314
• Update for Zeebe 0.18.
415
• Remove `ZBClient.listWorkflows` and `ZBClient.getWorkflow` - the broker no longer provides a query API.
516
• Remove `{redeploy: boolean}` option from `ZBClient.deployWorkflow` method. This relies on `listWorkflows`. This will be the default behaviour in a future release of Zeebe. See [zeebe/#1159](https://github.com/zeebe-io/zeebe/issues/1159).
6-
• Add client-side retry logic. Retries ZBClient gRPC command methods on failure due to [gRPC error code 14](https://github.com/grpc/grpc/blob/master/doc/statuscodes.md) (Transient Network Error). See [#40](https://github.com/creditsenseau/zeebe-client-node-js/issues/40).
17+
• Add client-side retry logic. Retries ZBClient gRPC command methods on failure due to [gRPC error code 14](https://github.com/grpc/grpc/blob/master/doc/statuscodes.md) (Transient Network Error). See [#41](https://github.com/creditsenseau/zeebe-client-node-js/issues/40).
718

819
# Version 1.2.0
920

README.md

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Docker-compose configurations for Zeebe are available at [https://github.com/zee
1313

1414
To enable that the client libraries can be easily supported to the Zeebe server we are remapping the version numbers, so that Major, Minor match the server application. Patches will be independent and indicate client updates.
1515

16+
NPM Package version 0.21.x supports Zeebe 0.21.x
17+
1618
NPM Package version 0.20.x supports Zeebe 0.20.x
1719

1820
NPM Package version 0.19.x supports Zeebe 0.19.x
@@ -25,6 +27,10 @@ NPM Package version 1.x.x supports Zeebe 0.15/0.16.
2527

2628
Protobuf fields of type `int64` are serialised as type string in the Node library. These fields are serialised as numbers (long) in the Go and Java client. See [grpc/#7229](https://github.com/grpc/grpc/issues/7229) for why the Node library serialises them as string. The Workflow instance key, and other fields that are of type long in other client libraries, are type string in this library. Fields of type `int32` are serialised as type number in the Node library.
2729

30+
## Scaffolding code from a BPM file
31+
32+
You can scaffold your worker code from a BPMN file with the `bin/zeebe-node-cli` command. Pass in the path to the BPMN file, and it will produce a file to implement it.
33+
2834
## Example Use
2935

3036
### Add the Library to your Project
@@ -85,14 +91,23 @@ const zbc = new ZB.ZBClient(gatewayAddress, {
8591

8692
Retry is provided by [promise-retry](https://www.npmjs.com/package/promise-retry), and the back-off strategy is simple ^2.
8793

88-
### TLS
94+
Additionally, the gRPC Client will contiually reconnect when in a failed state.
95+
96+
### OAuth
8997

90-
In case you need to connect to a secured endpoint, you can enable TLS.
98+
In case you need to connect to a secured endpoint with OAuth (such as Camunda Cloud), you can pass in OAuth credentials. This will enable TLS, and handle the OAuth flow to get / renew a JWT:
9199

92100
```typescript
93-
const zbc = new ZB.ZBClient(gatewayAddress, {
94-
tls: true,
95-
})
101+
const zbc = new ZB.ZBClient("103ca930-6da6-4df7-aa97-941eb1f85040.zeebe.camunda.io:443", {
102+
auth: {
103+
url: "https://login.cloud.camunda.io/oauth/token",
104+
audience: "103ca930-6da6-4df7-aa97-941eb1f85040.zeebe.camunda.io",
105+
clientId: "yStuGvJ6a1RQhy8DQpeXJ80yEpar3pXh",
106+
clientSecret:
107+
"WZahIGHjyj0-oQ7DZ_aH2wwNuZt5O8Sq0ZJTz0OaxfO7D6jaDBZxM_Q-BHRsiGO_",
108+
cache: true
109+
}
110+
}
96111
```
97112
98113
### Create a Task Worker
@@ -180,6 +195,22 @@ Call `complete.failure()` to fail the task. You must pass in a string message de
180195
complete.failure('This is a critical failure and will raise an incident', 0)
181196
```
182197
198+
### Long polling
199+
200+
With Zeebe 0.21 onward, long polling is supported for clients. Rather than polling continuously for work and getting nothing back, a client can poll once and leave the request open until work appears. This reduces network traffic and CPU utilization in the server. Every JobActivation Request is appended to the event log, so continuous polling can significantly impact broker performance, especially when an exporter is loaded (see [here](https://github.com/creditsenseau/zeebe-client-node-js/issues/64#issuecomment-520233275)).
201+
202+
To use long pollling, pass in a long poll timeout in milliseconds to the client. All workers created with that client will use it.
203+
204+
Long polling for workers is enabled in the ZBClient, like this:
205+
206+
```typescript
207+
const zbc = new ZBClient('serverAddress', {
208+
longPoll: 600000, // Ten minutes in millis
209+
})
210+
211+
const longPollingWorker = zbc.createWorker(uuid.v4(), 'task-type', handler)
212+
```
213+
183214
### Start a Workflow Instance
184215
185216
```javascript
@@ -262,18 +293,13 @@ This will produce output similar to:
262293
// Autogenerated constants for msg-start.bpmn
263294

264295
export enum TaskType = {
265-
266296
CONSOLE_LOG = "console-log"
267-
268297
};
269298

270299
export enum MessageName = {
271-
272300
MSG_EMIT_FRAME = "MSG-EMIT_FRAME",
273301
MSG_START_JOB = "MSG-START_JOB"
274-
275302
};
276-
277303
```
278304
279305
## Logging
@@ -344,10 +370,22 @@ npm run test:integration
344370
345371
For the failure test, you need to run Operate ([docker-compose config](https://github.com/zeebe-io/zeebe-docker-compose/blob/master/operate/docker-compose.yml)) and manually verify that an incident has been raised at [http://localhost:8080](http://localhost:8080).
346372
373+
### Writing Tests
374+
375+
Zeebe is inherently stateful, so integration tests need to be carefully isolated so that workers from one test do not service tasks in another test. Jest runs tests in a random order, so intermittent failures are the outcome of tests that mutate shared state.
376+
377+
For each feature:
378+
379+
- Use a unique bpmn process, named the same as the test file. Don't reuse processes between tests, because they are tightly coupled.
380+
- Name the task types with a namespace that matches the test name. This avoids workers from one test servicing tasks from another test, which causes unpredictable behaviour.
381+
- Cancel any workflows that do not run to completion in an `AfterAll` or `AfterEach` block. This avoids subsequent test runs interacting with workflows from a previous test run.
382+
- Ensure that there no Active workflows in the engine after running the integration tests have run. This manual check is to verify that there is no left-over state. (Note one exception: the Raise Incident test leaves the workflow open for manual verification in Operate).
383+
347384
## Contributors
348385
349386
| Name |
350387
| ------------------------------------------------------------ |
388+
| **[Colin Raddatz](https://github.com/ColRad)** |
351389
| **[Josh Wulf](https://github.com/jwulf)** |
352390
| **[Jarred Filmer](https://github.com/BrighTide)** |
353391
| **[Timothy Colbert](https://github.com/s3than)** |

bin/zeebe-node-cli

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env node
2+
const ZB = require("../")
3+
4+
const workfile = args[1]
5+
(async () => {
6+
console.log(await ZB.BpmnParser.scaffold(workflowFile));
7+
})();

docker/docker-compose.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

docker/monitor/docker-compose.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.
-11.2 MB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)