Skip to content

Commit 5092b10

Browse files
committed
updated linter and code to satisfy it
2 parents 1478c01 + b77535b commit 5092b10

Some content is hidden

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

56 files changed

+3259
-1606
lines changed

.circleci/config-local.yml

-86
This file was deleted.

.circleci/config.yml

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
version: 2
22

3-
prod_filters: &prod_filters # ignore any commit on any branch by default
3+
prod_filters: &prod_filters # Ignores any commit on any branch by default
44
branches:
55
ignore: /.*/
6-
# only act on version tags
6+
7+
# Only act on semver version tags
78
tags:
89
only:
9-
- /^[0-9]+\.[0-9]+\.[0-9]+$/
10+
- /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
1011

1112
jobs:
13+
# Runs the tests, including integration
1214
test:
1315
docker:
1416
- image: circleci/node:11.10.1
@@ -20,7 +22,7 @@ jobs:
2022
key: dependency-cache-{{ checksum "package.json" }}
2123
- run:
2224
name: npm-install
23-
command: npm install
25+
command: npm ci
2426
- save_cache:
2527
key: dependency-cache-{{ checksum "package.json" }}
2628
paths:
@@ -41,7 +43,9 @@ jobs:
4143
- run:
4244
name: build-typescript
4345
command: npm run build
44-
build:
46+
47+
# Publishes to npm
48+
publish:
4549
docker:
4650
- image: circleci/node:11.10.1
4751
steps:
@@ -52,7 +56,7 @@ jobs:
5256
key: dependency-cache-{{ checksum "package.json" }}
5357
- run:
5458
name: npm-install
55-
command: npm install
59+
command: npm ci
5660
- save_cache:
5761
key: dependency-cache-{{ checksum "package.json" }}
5862
paths:
@@ -63,17 +67,29 @@ jobs:
6367
- run:
6468
name: build
6569
command: npm run build
70+
- run:
71+
name: npmrc
72+
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
73+
- run:
74+
name: publish
75+
command: |
76+
if grep -qF "\"version\": \"$CIRCLE_TAG\"," package.json;then
77+
npm publish
78+
else
79+
echo "The package.json does not match the Git tag for this release"
80+
exit 1;
81+
fi
6682
6783
workflows:
6884
version: 2
6985
test:
7086
jobs:
7187
- test
72-
build-master:
88+
build-master: # Will only run when a tag is pushed
7389
jobs:
7490
- test:
7591
filters: *prod_filters
76-
- build:
92+
- publish:
7793
requires:
7894
- test
7995
filters: *prod_filters

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tag-version-prefix=""

README.md

+21-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ This is a Node.js gRPC client for [Zeebe](https://zeebe.io). It is written in Ty
77

88
Comprehensive API documentation is available [online](https://creditsenseau.github.io/zeebe-client-node-js/) and in the `docs` subdirectory.
99

10+
Docker-compose configurations for Zeebe are available at [https://github.com/zeebe-io/zeebe-docker-compose](https://github.com/zeebe-io/zeebe-docker-compose).
11+
1012
## Versioning
1113

1214
NPM Package version 1.x.x supports Zeebe 0.15/0.16.
@@ -123,6 +125,18 @@ zbc.createWorker('test-worker', 'console-log', maybeFaultyHandler, {
123125
})
124126
```
125127

128+
### Completing tasks with success or failure
129+
130+
To complete a task, the task worker handler function receives a `complete` method. This method has a `success` and a `failure` method (as well as being able to be called directly). Calling the method directly - `complete()` is the same as calling `complete.success()`.
131+
132+
Call `complete.success()` (or just `complete()`) passing in a optional plain old JavaScript object (POJO) - a key:value map. These are variable:value pairs that will be used to update the workflow state in the broker.
133+
134+
Call `complete.failure()` to fail the task. You must pass in a string message describing the failure. The client library decrements the retry count, and the broker handles the retry logic. If the failure is a hard failure and should cause an incident to be raised in Operate, then pass in `0` for the optional second parameter, `retries`:
135+
136+
```javascript
137+
complete.failure('This is a critical failure and will raise an incident', 0)
138+
```
139+
126140
### Start a Workflow Instance
127141

128142
```javascript
@@ -162,9 +176,9 @@ zbc.publishMessage({
162176
```
163177

164178
You can also publish a message targeting a [Message Start Event](https://github.com/zeebe-io/zeebe/issues/1858).
165-
In this case, there is no correlation key, and all Message Start events that match the `name` property will receive the message.
179+
In this case, the correlation key is optional, and all Message Start events that match the `name` property will receive the message.
166180

167-
You can use the `publishStartMessage()` method to publish a message with no correlation key (it will be set to `__MESSAGE_START_EVENT__` in the background):
181+
You can use the `publishStartMessage()` method to publish a message with no correlation key (it will be set to a random uuid in the background):
168182

169183
```javascript
170184
const zbc = new ZB.ZBClient('localhost:26500')
@@ -176,6 +190,8 @@ zbc.publishStartMessage({
176190
})
177191
```
178192

193+
Both normal messages and start messages can be published idempotently by setting both the `messageId` and the `correlationKey`. They will only ever be correlated once. See: [A message can be published idempotent](https://github.com/zeebe-io/zeebe/issues/1012).
194+
179195
### Graceful Shutdown
180196

181197
To drain workers, call the `close()` method of the ZBClient. This causes all workers using that client to stop polling for jobs, and returns a Promise that resolves when all active jobs have either finished or timed out.
@@ -267,7 +283,7 @@ Integration tests are in the `src/__tests__/integration` directory.
267283
They require a Zeebe broker to run. You can run them using the [Circle CI CLI](https://circleci.com/docs/2.0/local-cli/):
268284

269285
```bash
270-
circleci local execute -c .circleci/config-local.yml --job test
286+
circleci local execute -c .circleci/config.yml --job test
271287
```
272288

273289
Or you can start a dockerised broker:
@@ -282,3 +298,5 @@ And then run them manually:
282298
```bash
283299
npm run test:integration
284300
```
301+
302+
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).

0 commit comments

Comments
 (0)