modulepackage
2.3.11+incompatible
Repository: https://github.com/agilize/camunda-client-go.git
Documentation: pkg.go.dev
# README
Camunda REST API client for golang
Installation
go get github.com/agilize/camunda-client-go
Usage
Create client:
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:
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:
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
Usage for External task
Create external task processor:
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:
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:
go test -v -race ./...
Run linter:
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.42.0 golangci-lint run -v
Integration tests:
docker run --rm --name camunda -p 8080:8080 camunda/camunda-bpm-platform
go test -tags=integration -failfast ./...
Examples:
Go to examples directory 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 [email protected]
# Functions
NewClient a create new instance Client.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
# Structs
Client a client for Camunda API.
ClientOptions a client options.
Deployment a client for Deployment API.
Error a custom error type.
ExternalTask a client for ExternalTask API.
No description provided by the author
Message a client for Message API.
ProcessDefinition a client for ProcessDefinition.
ProcessInstance a client for ProcessInstance API.
QueryComplete a query for Complete request.
QueryExtendLock a query for ExtendLock request.
QueryFetchAndLock query for FetchAndLock request.
QueryFetchAndLockTopic a JSON array of topic objects for which external tasks should be fetched.
QueryGetListPost a query for ListPost request.
QueryHandleBPMNError a query for HandleBPMNError request.
QueryHandleFailure a query for HandleFailure request.
QueryListPostSorting a JSON array of criteria to sort the result by.
QueryProcessDefinitionBy path builder.
QueryProcessInstanceVariableBy path builder.
QuerySetRetriesAsync a query for SetRetriesAsync request.
QuerySetRetriesSync a query for SetRetriesSync request.
QueryUserTaskComplete a query for Complete user task request.
ReqActivateOrSuspendById response ActivateOrSuspendById.
ReqActivateOrSuspendByKey response ActivateOrSuspendByKey.
ReqDeleteHistoryProcessInstance a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqDeleteProcessInstance a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqDeploymentCreate a request to deployment create.
ReqHistoricProcessInstanceJobRetries a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqHistoryDeleteProcessInstance a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqHistoryProcessInstanceQuery a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqHistoryVariableInstanceQuery a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqMessage a request to send a message.
ReqModifyProcessInstance a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqModifyProcessInstanceInstruction a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqModifyProcessVariables a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqProcessInstanceActivateSuspend a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqProcessInstanceJobRetries a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqProcessInstanceQuery a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqProcessInstanceVariables a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqProcessVariable a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqProcessVariableQuery a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqProcessVariableValueInfo a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqRedeploy a request to redeploy.
ReqRestartInstance a request to restart instance.
ReqSort json representing sort criteria.
ReqStartInstance a JSON object with the following properties: (at least an empty JSON object {} or an empty request body).
ReqStartInstructions a JSON array of instructions that specify which activities to start the process instance at.
ReqSubmitStartForm request a SubmitStartForm.
ResActivityInstanceIncident a response object for process activity instance incident.
ResActivityInstanceStatistics a JSON array containing statistics results per activity.
ResActivityInstanceStatisticsIncident a statistics incident.
ResBatch a JSON object corresponding to the Batch interface in the engine.
ResBPMNProcessDefinition a JSON object containing the id of the definition and the BPMN 2.0 XML.
ResCaseDefinition a JSON object corresponding to the CaseDefinition interface in the engine.
ResCount a count response.
ResDecisionDefinition a JSON object corresponding to the DecisionDefinition interface in the engine.
ResDecisionRequirementsDefinition a JSON object corresponding to the DecisionRequirementsDefinition interface in the engine.
ResDeployment a JSON array of deployment objects.
ResDeploymentCreate a JSON object corresponding to the DeploymentWithDefinitions interface in the engine.
ResDeploymentResource a JSON array containing all deployment resources of the given deployment.
ResExternalTask a ExternalTask response.
ResGetStartFormKey a response from GetStartFormKey method.
ResHistoryProcessInstance a response object for process instance.
ResHistoryProcessInstanceDurationReport a response object for history process instance duration report.
ResHistoryVariableInstance a response object for history variable instance.
ResInstanceStatistics a JSON array containing statistics results per process definition.
ResLink a link struct.
ResLockedExternalTask a response FetchAndLock method.
ResProcessActivityInstance a response object for process activity instance.
ResProcessDefinition a JSON object corresponding to the ProcessDefinition interface in the engine.
ResProcessInstance a response object for process instance.
ResProcessTransitionInstance a response object for process transition instance.
ResProcessVariable a response object for process variable.
ResProcessVariableValueInfo variable value info.
ResStartedProcessDefinition ProcessDefinition for started.
ReqSubmitStartForm response rrom SubmitStartForm method.
Tenant a client for Tenant.
Time a custom time format.
UserTask camunda user task.
UserTaskGetListQuery query for GetList,.
UserTaskResponse get task response.
ValueInfo a value info in variable.
Variable a variable.
VariableFilterExpression filter expression.
VariableSet a variable for set.