https://github.com/citilinkru/camunda-client-go
Camunda REST API client for golang
https://github.com/citilinkru/camunda-client-go
api-client bpmn bpms camunda camunda-bpm camunda-bpm-platform camunda-external-task camunda-framework golang-library rest-client
Last synced: 5 months ago
JSON representation
Camunda REST API client for golang
- Host: GitHub
- URL: https://github.com/citilinkru/camunda-client-go
- Owner: citilinkru
- License: mit
- Created: 2019-03-27T16:07:24.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-13T15:32:00.000Z (over 2 years ago)
- Last Synced: 2025-08-18T08:58:31.544Z (10 months ago)
- Topics: api-client, bpmn, bpms, camunda, camunda-bpm, camunda-bpm-platform, camunda-external-task, camunda-framework, golang-library, rest-client
- Language: Go
- Homepage:
- Size: 92.8 KB
- Stars: 151
- Watchers: 14
- Forks: 61
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: history.go
- License: LICENSE
Awesome Lists containing this project
README
# Camunda REST API client for golang
[](https://goreportcard.com/report/github.com/citilinkru/camunda-client-go)
[](https://codecov.io/gh/citilinkru/camunda-client-go)
[](https://pkg.go.dev/github.com/citilinkru/camunda-client-go)
[](https://github.com/citilinkru/camunda-client-go/releases/latest)
Installation
-----------
go get github.com/citilinkru/camunda-client-go/v3
Usage
-----------
Create client:
```go
client := camunda_client_go.NewClient(camunda_client_go.ClientOptions{
EndpointUrl: "http://localhost:8080/engine-rest",
ApiUser: "demo",
ApiPassword: "demo",
Timeout: time.Second * 10,
})
```
Create deployment:
```go
file, err := os.Open("demo.bpmn")
if err != nil {
fmt.Printf("Error read file: %s\n", err)
return
}
result, err := client.Deployment.Create(camunda_client_go.ReqDeploymentCreate{
DeploymentName: "DemoProcess",
Resources: map[string]interface{}{
"demo.bpmn": file,
},
})
if err != nil {
fmt.Printf("Error deploy process: %s\n", err)
return
}
fmt.Printf("Result: %#+v\n", result)
```
Start instance:
```go
processKey := "demo-process"
result, err := client.ProcessDefinition.StartInstance(
camunda_client_go.QueryProcessDefinitionBy{Key: &processKey},
camunda_client_go.ReqStartInstance{},
)
if err != nil {
fmt.Printf("Error start process: %s\n", err)
return
}
fmt.Printf("Result: %#+v\n", result)
```
More examples
-----------
[Examples documentation](examples/README.md)
Usage for External task
-----------
Create external task processor:
```go
logger := func(err error) {
fmt.Println(err.Error())
}
asyncResponseTimeout := 5000
proc := processor.NewProcessor(client, &processor.Options{
WorkerId: "demo-worker",
LockDuration: time.Second * 5,
MaxTasks: 10,
MaxParallelTaskPerHandler: 100,
AsyncResponseTimeout: &asyncResponseTimeout,
}, logger)
```
Add and subscribe external task handler:
```go
proc.AddHandler(
[]*camunda_client_go.QueryFetchAndLockTopic{
{TopicName: "HelloWorldSetter"},
},
func(ctx *processor.Context) error {
fmt.Printf("Running task %s. WorkerId: %s. TopicName: %s\n", ctx.Task.Id, ctx.Task.WorkerId, ctx.Task.TopicName)
err := ctx.Complete(processor.QueryComplete{
Variables: &map[string]camunda_client_go.Variable {
"result": {Value: "Hello world!", Type: "string"},
},
})
if err != nil {
fmt.Printf("Error set complete task %s: %s\n", ctx.Task.Id, err)
return ctx.HandleFailure(processor.QueryHandleFailure{
ErrorMessage: &errTxt,
Retries: &retries,
RetryTimeout: &retryTimeout,
})
}
fmt.Printf("Task %s completed\n", ctx.Task.Id)
return nil
},
)
```
Features
-----------
* Support api version `7.11`
* Full support API `External Task`
* Full support API `Process Definition`
* Full support API `Process Instance`
* Full support API `Deployment`
* Partial support API `History`
* Partial support API `Tenant`
* Without external dependencies
Road map
-----------
* Full coverage by tests
* Full support references api
Testing
-----------
Unit-tests:
```bash
go test -v -race ./...
```
Run linter:
```bash
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.45.2 golangci-lint run -v
```
Integration tests:
```bash
docker run --rm --name camunda -p 8080:8080 camunda/camunda-bpm-platform
```
```bash
go test -tags=integration -failfast ./...
```
Examples:
---------
Go to [examples directory](examples/README.md) and follow the instructions to run the examples.
CONTRIBUTE
-----------
* write code
* run `go fmt ./...`
* run all linters and tests (see above)
* run all examples (see above)
* create a PR describing the changes
LICENSE
-----------
MIT
AUTHOR
-----------
Konstantin Osipov