You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61-8Lines changed: 61 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,6 @@ Once locked, the custom logic is responsible for signalling over REST that the w
10
10
This project makes implementing such custom logic in Golang easy by implementing the low-level details of the REST API and focus on the actual custom business logic.
11
11
Integrations for other languages are also available.
12
12
13
-
## Authentication
14
-
15
-
There are default implementations for basic authentication and bearer tokens..
16
-
Basic Auth: `flowable.SetAuth("admin", "test")`
17
-
Bearer token: `flowable.SetBearerToken("token")`
18
13
19
14
## Installation
20
15
@@ -26,6 +21,14 @@ However, the project is licensed with the Apache 2 license and can be readily cl
26
21
27
22
## Setup
28
23
24
+
### Authentication
25
+
26
+
There are default implementations for basic authentication and bearer tokens..
27
+
Basic Auth: `flowable.SetAuth("admin", "test")`
28
+
Bearer token: `flowable.SetBearerToken("token")`
29
+
30
+
### Job Acquisition
31
+
29
32
The **main.go** file contains the work job acquisition parameters (`acquireParams`). This is where job acquisitions parameters are declared including base url, poll interval, topic name, retry count, task retrieval batch size.
go flowable.Subscribe(acquireParams, worker.ExternalWorker)
53
56
```
54
57
55
-
The sample worker business logic is held in `worker/external_worker.go` and supports access to input parameters from the inbound _body_ variable. If any errors were reported from the REST call or parsing of the job, an http _status_ variable will be available — values >= 400 should be considered errors. Handler results support _success_, _fail_, _bpmnError_ and _cmmnTerminate_ responses.
56
-
57
-
## Logging
58
+
### Logging
58
59
59
60
-**Default:** logging is enabled by default.
60
61
-**Control:** toggle logging at runtime from `main.go` using:
func ExternalWorker(status int, body string) (flowable.HandlerStatus, *flowable.HandlerResult) {
82
+
83
+
// Initialize return status
84
+
85
+
res := &flowable.HandlerResult{
86
+
Status: flowable.HandlerSuccess,
87
+
WorkerId: "",
88
+
Variables: []flowable.HandlerVariable{},
89
+
ErrorCode: "",
90
+
}
91
+
92
+
log.Printf("CustomWorker: processed job.")
93
+
res.Status = flowable.HandlerSuccess
94
+
return res.Status, res
95
+
}
96
+
97
+
func main() {
98
+
99
+
flowable.SetAuth("admin", "test")
100
+
acquireParams := flowable.AcquireRequest{
101
+
Topic: "testing",
102
+
LockDuration: "PT10M",
103
+
NumberOfTasks: 1,
104
+
NumberOfRetries: 5,
105
+
WorkerId: "worker1",
106
+
ScopeType: "bpmn",
107
+
URL: "http://localhost:8090",
108
+
Interval: 10 * time.Second,
109
+
}
110
+
111
+
go flowable.Subscribe(acquireParams, ExternalWorker)
112
+
113
+
// Ennsure application keeps running..
114
+
select {}
115
+
}
116
+
```
117
+
118
+
A more complete sample worker can be found in `worker/external_worker.go` and supports access to input parameters from the inbound _body_ variable. If any errors were reported from the REST call or parsing of the job, an http _status_ variable will be available — values >= 400 should be considered errors. Handler results support _success_, _fail_, _bpmnError_ and _cmmnTerminate_ responses.
119
+
120
+
121
+
69
122
## Integration Tests With Cached HTTP Cassettes
70
123
71
124
Integration tests in `test/flowable_integration_test.go` use a VCR-style recorder (`go-vcr`) and store HTTP cassettes in `test/fixtures/cassettes`.
0 commit comments