Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
liderman committed Nov 28, 2021
1 parent 5d3ddef commit 5b9b9ff
Show file tree
Hide file tree
Showing 20 changed files with 75 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fetch-depth: 2
- uses: actions/setup-go@v2
with:
go-version: '1.13'
go-version: '1.14'
- name: Run coverage
run: go test -race -coverprofile=coverage.txt -covermode=atomic
- name: Upload coverage to Codecov
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
golangci:
strategy:
matrix:
go-version: [1.13, 1.14, 1.15, 1.16]
go-version: [1.14, 1.15, 1.16]
name: lint
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.13, 1.14, 1.15, 1.16]
go-version: [1.14, 1.15, 1.16]
name: test
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Installation
-----------
go get github.com/citilinkru/camunda-client-go/v2
go get github.com/citilinkru/camunda-client-go

Usage
-----------
Expand Down Expand Up @@ -70,7 +70,7 @@ logger := func(err error) {
fmt.Println(err.Error())
}
asyncResponseTimeout := 5000
proc := processor.NewProcessor(client, &processor.ProcessorOptions{
proc := processor.NewProcessor(client, &processor.Options{
WorkerId: "demo-worker",
LockDuration: time.Second * 5,
MaxTasks: 10,
Expand All @@ -82,7 +82,7 @@ proc := processor.NewProcessor(client, &processor.ProcessorOptions{
Add and subscribe external task handler:
```go
proc.AddHandler(
&[]camunda_client_go.QueryFetchAndLockTopic{
[]*camunda_client_go.QueryFetchAndLockTopic{
{TopicName: "HelloWorldSetter"},
},
func(ctx *processor.Context) error {
Expand Down Expand Up @@ -136,7 +136,7 @@ go test -v -race ./...

Run linter:
```bash
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.40 golangci-lint run -v
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.42.0 golangci-lint run -v
```

Integration tests:
Expand Down
4 changes: 2 additions & 2 deletions client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func init() {
file, err := os.Open("examples/deployment/HelloWorld.bpmn")
if err != nil {
fmt.Printf("Error read file: %s\n", err)
os.Exit(1)
return
}
_, err = client.Deployment.Create(ReqDeploymentCreate{
DeploymentName: "HelloWorldProcessDemo",
Expand All @@ -36,6 +36,6 @@ func init() {
})
if err != nil {
fmt.Printf("Error deploy process: %s\n", err)
os.Exit(1)
return
}
}
2 changes: 1 addition & 1 deletion examples/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
camundaclientgo "github.com/citilinkru/camunda-client-go/v2"
camundaclientgo "github.com/citilinkru/camunda-client-go"
"os"
"time"
)
Expand Down
2 changes: 1 addition & 1 deletion examples/history/processinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"flag"
"fmt"
camundaclientgo "github.com/citilinkru/camunda-client-go/v2"
camundaclientgo "github.com/citilinkru/camunda-client-go"
"os"
"time"
)
Expand Down
2 changes: 1 addition & 1 deletion examples/process-instance/getprocessinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"time"

camundaclientgo "github.com/citilinkru/camunda-client-go/v2"
camundaclientgo "github.com/citilinkru/camunda-client-go"
)

func main() {
Expand Down
10 changes: 5 additions & 5 deletions examples/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"fmt"
camundaclientgo "github.com/citilinkru/camunda-client-go/v2"
"github.com/citilinkru/camunda-client-go/v2/processor"
camundaclientgo "github.com/citilinkru/camunda-client-go"
"github.com/citilinkru/camunda-client-go/processor"
"time"
)

Expand All @@ -18,7 +18,7 @@ func main() {
logger := func(err error) {
fmt.Println(err.Error())
}
proc := processor.NewProcessor(client, &processor.ProcessorOptions{
proc := processor.NewProcessor(client, &processor.Options{
WorkerId: "hello-world-worker",
LockDuration: time.Second * 5,
MaxTasks: 10,
Expand All @@ -27,7 +27,7 @@ func main() {
}, logger)

proc.AddHandler(
&[]camundaclientgo.QueryFetchAndLockTopic{
[]*camundaclientgo.QueryFetchAndLockTopic{
{TopicName: "PrintHello"},
},
func(ctx *processor.Context) error {
Expand All @@ -51,7 +51,7 @@ func main() {
)

proc.AddHandler(
&[]camundaclientgo.QueryFetchAndLockTopic{
[]*camundaclientgo.QueryFetchAndLockTopic{
{TopicName: "PrintWorld"},
},
func(ctx *processor.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion examples/start-process/start-process.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
camundaclientgo "github.com/citilinkru/camunda-client-go/v2"
camundaclientgo "github.com/citilinkru/camunda-client-go"
"time"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/user-task/complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
camundaclientgo "github.com/citilinkru/camunda-client-go/v2"
camundaclientgo "github.com/citilinkru/camunda-client-go"
"os"
"time"
)
Expand Down
10 changes: 5 additions & 5 deletions external-task.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ type QueryGetListPost struct {
// Filter by the id of the activity that an external task is created for
ActivityId *string `json:"activityId,omitempty"`
// Filter by the comma-separated list of ids of the activities that an external task is created for
ActivityIdIn *[]string `json:"activityIdIn,omitempty"`
ActivityIdIn []string `json:"activityIdIn,omitempty"`
// Filter by the id of the execution that an external task belongs to
ExecutionId *string `json:"executionId,omitempty"`
// Filter by the id of the process instance that an external task belongs to
ProcessInstanceId *string `json:"processInstanceId,omitempty"`
// Filter by the id of the process definition that an external task belongs to
ProcessDefinitionId *string `json:"processDefinitionId,omitempty"`
// Filter by a comma-separated list of tenant ids. An external task must have one of the given tenant ids
TenantIdIn *[]string `json:"tenantIdIn,omitempty"`
TenantIdIn []string `json:"tenantIdIn,omitempty"`
// Only include active tasks. Value may only be true, as false matches any external task
Active *bool `json:"active,omitempty"`
// Only include suspended tasks. Value may only be true, as false matches any external task
Expand Down Expand Up @@ -114,7 +114,7 @@ type QueryFetchAndLock struct {
AsyncResponseTimeout *int `json:"asyncResponseTimeout,omitempty"`
// A JSON array of topic objects for which external tasks should be fetched.
// The returned tasks may be arbitrarily distributed among these topics
Topics *[]QueryFetchAndLockTopic `json:"topics,omitempty"`
Topics []*QueryFetchAndLockTopic `json:"topics,omitempty"`
}

// QueryFetchAndLockTopic a JSON array of topic objects for which external tasks should be fetched
Expand All @@ -126,15 +126,15 @@ type QueryFetchAndLockTopic struct {
// A JSON array of String values that represent variable names. For each result task belonging to this topic,
// the given variables are returned as well if they are accessible from the external task's execution.
// If not provided - all variables will be fetched
Variables *[]string `json:"variables,omitempty"`
Variables []string `json:"variables,omitempty"`
// If true only local variables will be fetched
LocalVariables *bool `json:"localVariables,omitempty"`
// A String value which enables the filtering of tasks based on process instance business key
BusinessKey *string `json:"businessKey,omitempty"`
// Filter tasks based on process definition id
ProcessDefinitionId *string `json:"processDefinitionId,omitempty"`
// Filter tasks based on process definition ids
ProcessDefinitionIdIn *[]string `json:"processDefinitionIdIn,omitempty"`
ProcessDefinitionIdIn []string `json:"processDefinitionIdIn,omitempty"`
// Filter tasks based on process definition key
ProcessDefinitionKey *string `json:"processDefinitionKey,omitempty"`
// Filter tasks based on process definition keys
Expand Down
6 changes: 3 additions & 3 deletions external-task_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func TestFetchAndLockIntegration(t *testing.T) {
assert.NoError(t, err)

// wait processing StartInstance in camunda
time.Sleep(time.Second * 10)
time.Sleep(time.Second * 15)

tasks, err := client.ExternalTask.FetchAndLock(QueryFetchAndLock{
WorkerId: "test-fetch-and-lock-integration",
MaxTasks: 10,
Topics: &[]QueryFetchAndLockTopic{
Topics: []*QueryFetchAndLockTopic{
{
LockDuration: 1000,
TopicName: "PrintHello",
Expand All @@ -53,7 +53,7 @@ func TestFetchAndLockIntegration(t *testing.T) {
tasks, err = client.ExternalTask.FetchAndLock(QueryFetchAndLock{
WorkerId: "test-fetch-and-lock-integration",
MaxTasks: 10,
Topics: &[]QueryFetchAndLockTopic{
Topics: []*QueryFetchAndLockTopic{
{
LockDuration: 1000,
TopicName: "PrintHello",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/citilinkru/camunda-client-go/v2
module github.com/citilinkru/camunda-client-go

go 1.14

Expand Down
34 changes: 17 additions & 17 deletions history.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ReqHistoryProcessInstanceQuery struct {
// Filter by process instance id.
ProcessInstanceId *string `json:"processInstanceId"`
// Filter by a list of process instance ids. Must be a JSON array of Strings.
ProcessInstanceIds *[]string `json:"processInstanceIds"`
ProcessInstanceIds []string `json:"processInstanceIds"`
// Filter by process instance business key.
BusinessKey *string `json:"processInstanceBusinessKey"`
// Filter by process instance business key that the parameter is a substring of.
Expand All @@ -25,10 +25,10 @@ type ReqHistoryProcessInstanceQuery struct {
ProcessDefinitionKey *string `json:"processDefinitionKey"`
// Filter by a list of process definition keys. A process instance must have one of the
// given process definition keys. Must be a JSON array of Strings.
ProcessDefinitionKeyIn *[]string `json:"processDefinitionKeyIn"`
ProcessDefinitionKeyIn []string `json:"processDefinitionKeyIn"`
// Exclude instances by a list of process definition keys. A process instance must not have one of the
// given process definition keys. Must be a JSON array of Strings.
ProcessDefinitionKeyNotIn *[]string `json:"processDefinitionKeyNotIn"`
ProcessDefinitionKeyNotIn []string `json:"processDefinitionKeyNotIn"`
// Filter by the name of the process definition the instances run on.
ProcessDefinitionName *string `json:"processDefinitionName"`
// Filter by process definition names that the parameter is a substring of.
Expand Down Expand Up @@ -75,21 +75,21 @@ type ReqHistoryProcessInstanceQuery struct {
IncidentMessageLike *string `json:"incidentMessageLike"`
// Filter by a list of tenant ids. A process instance must have one of the given tenant ids.
// Must be a JSON array of Strings.
TenantIdIn *[]string `json:"tenantIdIn"`
TenantIdIn []string `json:"tenantIdIn"`
// Only include process instances which belong to no tenant. Value may only be true, as false is the default behavior.
WithoutTenantId *bool `json:"withoutTenantId"`
// Filter by a list of activity ids. A process instance must currently wait in a leaf activity with one of the given activity ids.
ActivityIdIn *[]string `json:"activityIdIn"`
ActivityIdIn []string `json:"activityIdIn"`
// Restrict to instance that executed an activity with one of given ids.
ExecutedActivityIdIn *[]string `json:"executedActivityIdIn"`
ExecutedActivityIdIn []string `json:"executedActivityIdIn"`
// Restrict the query to all process instances that are top level process instances.
RootProcessInstances *bool `json:"rootProcessInstances"`
// Restrict the query to all process instances that are leaf instances. (i.e. don't have any sub instances)
LeafProcessInstances *bool `json:"leafProcessInstances"`
// Only include process instances which process definition has no tenant id.
ProcessDefinitionWithoutTenantId *bool `json:"processDefinitionWithoutTenantId"`
// A JSON array to only include process instances that have variables with certain values.
Variables *[]ReqProcessVariableQuery `json:"variables"`
Variables []ReqProcessVariableQuery `json:"variables"`
// Match all variable names in this query case-insensitively.
// If set to true variable-Name and variable-name are treated as equal.
VariableNamesIgnoreCase *bool `json:"variableNamesIgnoreCase"`
Expand All @@ -100,11 +100,11 @@ type ReqHistoryProcessInstanceQuery struct {
// A process instance matches a nested query if it fulfills at least one of the query's predicates.
// With multiple nested queries, a process instance must fulfill at least one predicate of each query.
// All process instance query properties can be used except for: sorting.
OrQueries *[]ReqProcessInstanceQuery `json:"orQueries"`
OrQueries []ReqProcessInstanceQuery `json:"orQueries"`
// A JSON array of criteria to sort the result by.
// Each element of the array is a JSON object that specifies one ordering.
// The position in the array identifies the rank of an ordering, i.e., whether it is primary, secondary, etc.
Sorting *[]ReqSort `json:"sorting"`
Sorting []ReqSort `json:"sorting"`
// Restrict to instance that was started before the given date.
// By default, the date must have the format yyyy-MM-dd'T'HH:mm:ss.SSSZ, e.g., 2013-01-23T14:42:45.000+0200.
StartedBefore *string `json:"startedBefore"`
Expand Down Expand Up @@ -135,7 +135,7 @@ type ReqHistoryProcessInstanceQuery struct {
// or an empty request body)
type ReqHistoryDeleteProcessInstance struct {
// A list process instance ids to delete.
HistoricProcessInstanceIds *[]string `json:"historicProcessInstanceIds,omitempty"`
HistoricProcessInstanceIds []string `json:"historicProcessInstanceIds,omitempty"`
// A process instance query
HistoricProcessInstanceQuery *ReqProcessInstanceQuery `json:"historicProcessInstanceQuery,omitempty"`
// A string with delete reason.
Expand All @@ -149,15 +149,15 @@ type ReqHistoryVariableInstanceQuery struct {
VariableNameLike *string `json:"variableNameLike"`
VariableValue interface{} `json:"variableValue"`
ProcessInstanceId *string `json:"processInstanceId"`
ProcessInstanceIdIn *[]string `json:"processInstanceIdIn"`
ProcessInstanceIdIn []string `json:"processInstanceIdIn"`
ProcessDefinitionId *string `json:"process_definition_id"`
ExecutionIdIn *[]string `json:"executionIdIn"`
ExecutionIdIn []string `json:"executionIdIn"`
CaseInstanceId *string `json:"caseInstanceId"`
CaseExecutionIdIn *[]string `json:"caseExecutionIdIn"`
CaseActivityIdIn *[]string `json:"caseActivityIdIn"`
TaskIdIn *[]string `json:"taskIdIn"`
ActivityInstanceIdIn *[]string `json:"activityInstanceIdIn"`
TenantIdIn *[]string `json:"tenantIdIn"`
CaseExecutionIdIn []string `json:"caseExecutionIdIn"`
CaseActivityIdIn []string `json:"caseActivityIdIn"`
TaskIdIn []string `json:"taskIdIn"`
ActivityInstanceIdIn []string `json:"activityInstanceIdIn"`
TenantIdIn []string `json:"tenantIdIn"`
}

// ResHistoryProcessInstance a response object for process instance
Expand Down
4 changes: 2 additions & 2 deletions process-definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type ReqStartInstance struct {
CaseInstanceId *string `json:"caseInstanceId,omitempty"`
// Optional. A JSON array of instructions that specify which activities to start the process instance at.
// If this property is omitted, the process instance starts at its default blank start event
StartInstructions *[]ReqStartInstructions `json:"startInstructions,omitempty"`
StartInstructions []ReqStartInstructions `json:"startInstructions,omitempty"`
// Skip execution listener invocation for activities that are started or ended as part of this request
// Note: This option is currently only respected when start instructions are submitted via
// the startInstructions property
Expand All @@ -109,7 +109,7 @@ type ReqRestartInstance struct {
HistoricProcessInstanceQuery *string `json:"historicProcessInstanceQuery,omitempty"`
// Optional. A JSON array of instructions that specify which activities to start the process instance at.
// If this property is omitted, the process instance starts at its default blank start event
StartInstructions *[]ReqStartInstructions `json:"startInstructions,omitempty"`
StartInstructions []ReqStartInstructions `json:"startInstructions,omitempty"`
// Skip execution listener invocation for activities that are started or ended as part of this request
// Note: This option is currently only respected when start instructions are submitted via
// the startInstructions property
Expand Down
Loading

0 comments on commit 5b9b9ff

Please sign in to comment.