Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 61 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ Once locked, the custom logic is responsible for signalling over REST that the w
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.
Integrations for other languages are also available.

## Authentication

There are default implementations for basic authentication and bearer tokens..
Basic Auth: `flowable.SetAuth("admin", "test")`
Bearer token: `flowable.SetBearerToken("token")`

## Installation

Expand All @@ -26,6 +21,14 @@ However, the project is licensed with the Apache 2 license and can be readily cl

## Setup

### Authentication

There are default implementations for basic authentication and bearer tokens..
Basic Auth: `flowable.SetAuth("admin", "test")`
Bearer token: `flowable.SetBearerToken("token")`

### Job Acquisition

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.


Expand All @@ -52,9 +55,7 @@ acquireParams := flowable.AcquireRequest{
go flowable.Subscribe(acquireParams, worker.ExternalWorker)
```

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.

## Logging
### Logging

- **Default:** logging is enabled by default.
- **Control:** toggle logging at runtime from `main.go` using:
Expand All @@ -66,6 +67,58 @@ flowable.SetEnableLogging(false) // disable

When logging is disabled the library will suppress internal `log.Printf` messages.

## Samples

```
package main

import (
"time"
"log"
"github.com/flowable/flowable-external-client-golang/flowable"
)

func ExternalWorker(status int, body string) (flowable.HandlerStatus, *flowable.HandlerResult) {

// Initialize return status

res := &flowable.HandlerResult{
Status: flowable.HandlerSuccess,
WorkerId: "",
Variables: []flowable.HandlerVariable{},
ErrorCode: "",
}

log.Printf("CustomWorker: processed job.")
res.Status = flowable.HandlerSuccess
return res.Status, res
}

func main() {

flowable.SetAuth("admin", "test")
acquireParams := flowable.AcquireRequest{
Topic: "testing",
LockDuration: "PT10M",
NumberOfTasks: 1,
NumberOfRetries: 5,
WorkerId: "worker1",
ScopeType: "bpmn",
URL: "http://localhost:8090",
Interval: 10 * time.Second,
}

go flowable.Subscribe(acquireParams, ExternalWorker)

// Ennsure application keeps running..
select {}
}
```

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.



## Integration Tests With Cached HTTP Cassettes

Integration tests in `test/flowable_integration_test.go` use a VCR-style recorder (`go-vcr`) and store HTTP cassettes in `test/fixtures/cassettes`.
Expand Down
Loading