Skip to content

Commit 5b9b9ff

Browse files
committed
Code refactoring
1 parent 5d3ddef commit 5b9b9ff

20 files changed

+75
-77
lines changed

.github/workflows/codecov.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
fetch-depth: 2
1010
- uses: actions/setup-go@v2
1111
with:
12-
go-version: '1.13'
12+
go-version: '1.14'
1313
- name: Run coverage
1414
run: go test -race -coverprofile=coverage.txt -covermode=atomic
1515
- name: Upload coverage to Codecov

.github/workflows/golangci-lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
golangci:
88
strategy:
99
matrix:
10-
go-version: [1.13, 1.14, 1.15, 1.16]
10+
go-version: [1.14, 1.15, 1.16]
1111
name: lint
1212
runs-on: ubuntu-latest
1313
steps:

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
strategy:
99
matrix:
10-
go-version: [1.13, 1.14, 1.15, 1.16]
10+
go-version: [1.14, 1.15, 1.16]
1111
name: test
1212
runs-on: ubuntu-latest
1313
steps:

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Installation
88
-----------
9-
go get github.com/citilinkru/camunda-client-go/v2
9+
go get github.com/citilinkru/camunda-client-go
1010

1111
Usage
1212
-----------
@@ -70,7 +70,7 @@ logger := func(err error) {
7070
fmt.Println(err.Error())
7171
}
7272
asyncResponseTimeout := 5000
73-
proc := processor.NewProcessor(client, &processor.ProcessorOptions{
73+
proc := processor.NewProcessor(client, &processor.Options{
7474
WorkerId: "demo-worker",
7575
LockDuration: time.Second * 5,
7676
MaxTasks: 10,
@@ -82,7 +82,7 @@ proc := processor.NewProcessor(client, &processor.ProcessorOptions{
8282
Add and subscribe external task handler:
8383
```go
8484
proc.AddHandler(
85-
&[]camunda_client_go.QueryFetchAndLockTopic{
85+
[]*camunda_client_go.QueryFetchAndLockTopic{
8686
{TopicName: "HelloWorldSetter"},
8787
},
8888
func(ctx *processor.Context) error {
@@ -136,7 +136,7 @@ go test -v -race ./...
136136

137137
Run linter:
138138
```bash
139-
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.40 golangci-lint run -v
139+
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.42.0 golangci-lint run -v
140140
```
141141

142142
Integration tests:

client_integration_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func init() {
2626
file, err := os.Open("examples/deployment/HelloWorld.bpmn")
2727
if err != nil {
2828
fmt.Printf("Error read file: %s\n", err)
29-
os.Exit(1)
29+
return
3030
}
3131
_, err = client.Deployment.Create(ReqDeploymentCreate{
3232
DeploymentName: "HelloWorldProcessDemo",
@@ -36,6 +36,6 @@ func init() {
3636
})
3737
if err != nil {
3838
fmt.Printf("Error deploy process: %s\n", err)
39-
os.Exit(1)
39+
return
4040
}
4141
}

examples/deployment/deployment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
44
"fmt"
5-
camundaclientgo "github.com/citilinkru/camunda-client-go/v2"
5+
camundaclientgo "github.com/citilinkru/camunda-client-go"
66
"os"
77
"time"
88
)

examples/history/processinstance.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"flag"
55
"fmt"
6-
camundaclientgo "github.com/citilinkru/camunda-client-go/v2"
6+
camundaclientgo "github.com/citilinkru/camunda-client-go"
77
"os"
88
"time"
99
)

examples/process-instance/getprocessinstance.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"time"
66

7-
camundaclientgo "github.com/citilinkru/camunda-client-go/v2"
7+
camundaclientgo "github.com/citilinkru/camunda-client-go"
88
)
99

1010
func main() {

examples/processor/processor.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package main
22

33
import (
44
"fmt"
5-
camundaclientgo "github.com/citilinkru/camunda-client-go/v2"
6-
"github.com/citilinkru/camunda-client-go/v2/processor"
5+
camundaclientgo "github.com/citilinkru/camunda-client-go"
6+
"github.com/citilinkru/camunda-client-go/processor"
77
"time"
88
)
99

@@ -18,7 +18,7 @@ func main() {
1818
logger := func(err error) {
1919
fmt.Println(err.Error())
2020
}
21-
proc := processor.NewProcessor(client, &processor.ProcessorOptions{
21+
proc := processor.NewProcessor(client, &processor.Options{
2222
WorkerId: "hello-world-worker",
2323
LockDuration: time.Second * 5,
2424
MaxTasks: 10,
@@ -27,7 +27,7 @@ func main() {
2727
}, logger)
2828

2929
proc.AddHandler(
30-
&[]camundaclientgo.QueryFetchAndLockTopic{
30+
[]*camundaclientgo.QueryFetchAndLockTopic{
3131
{TopicName: "PrintHello"},
3232
},
3333
func(ctx *processor.Context) error {
@@ -51,7 +51,7 @@ func main() {
5151
)
5252

5353
proc.AddHandler(
54-
&[]camundaclientgo.QueryFetchAndLockTopic{
54+
[]*camundaclientgo.QueryFetchAndLockTopic{
5555
{TopicName: "PrintWorld"},
5656
},
5757
func(ctx *processor.Context) error {

examples/start-process/start-process.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
44
"fmt"
5-
camundaclientgo "github.com/citilinkru/camunda-client-go/v2"
5+
camundaclientgo "github.com/citilinkru/camunda-client-go"
66
"time"
77
)
88

examples/user-task/complete.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
44
"fmt"
5-
camundaclientgo "github.com/citilinkru/camunda-client-go/v2"
5+
camundaclientgo "github.com/citilinkru/camunda-client-go"
66
"os"
77
"time"
88
)

external-task.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ type QueryGetListPost struct {
7777
// Filter by the id of the activity that an external task is created for
7878
ActivityId *string `json:"activityId,omitempty"`
7979
// Filter by the comma-separated list of ids of the activities that an external task is created for
80-
ActivityIdIn *[]string `json:"activityIdIn,omitempty"`
80+
ActivityIdIn []string `json:"activityIdIn,omitempty"`
8181
// Filter by the id of the execution that an external task belongs to
8282
ExecutionId *string `json:"executionId,omitempty"`
8383
// Filter by the id of the process instance that an external task belongs to
8484
ProcessInstanceId *string `json:"processInstanceId,omitempty"`
8585
// Filter by the id of the process definition that an external task belongs to
8686
ProcessDefinitionId *string `json:"processDefinitionId,omitempty"`
8787
// Filter by a comma-separated list of tenant ids. An external task must have one of the given tenant ids
88-
TenantIdIn *[]string `json:"tenantIdIn,omitempty"`
88+
TenantIdIn []string `json:"tenantIdIn,omitempty"`
8989
// Only include active tasks. Value may only be true, as false matches any external task
9090
Active *bool `json:"active,omitempty"`
9191
// Only include suspended tasks. Value may only be true, as false matches any external task
@@ -114,7 +114,7 @@ type QueryFetchAndLock struct {
114114
AsyncResponseTimeout *int `json:"asyncResponseTimeout,omitempty"`
115115
// A JSON array of topic objects for which external tasks should be fetched.
116116
// The returned tasks may be arbitrarily distributed among these topics
117-
Topics *[]QueryFetchAndLockTopic `json:"topics,omitempty"`
117+
Topics []*QueryFetchAndLockTopic `json:"topics,omitempty"`
118118
}
119119

120120
// QueryFetchAndLockTopic a JSON array of topic objects for which external tasks should be fetched
@@ -126,15 +126,15 @@ type QueryFetchAndLockTopic struct {
126126
// A JSON array of String values that represent variable names. For each result task belonging to this topic,
127127
// the given variables are returned as well if they are accessible from the external task's execution.
128128
// If not provided - all variables will be fetched
129-
Variables *[]string `json:"variables,omitempty"`
129+
Variables []string `json:"variables,omitempty"`
130130
// If true only local variables will be fetched
131131
LocalVariables *bool `json:"localVariables,omitempty"`
132132
// A String value which enables the filtering of tasks based on process instance business key
133133
BusinessKey *string `json:"businessKey,omitempty"`
134134
// Filter tasks based on process definition id
135135
ProcessDefinitionId *string `json:"processDefinitionId,omitempty"`
136136
// Filter tasks based on process definition ids
137-
ProcessDefinitionIdIn *[]string `json:"processDefinitionIdIn,omitempty"`
137+
ProcessDefinitionIdIn []string `json:"processDefinitionIdIn,omitempty"`
138138
// Filter tasks based on process definition key
139139
ProcessDefinitionKey *string `json:"processDefinitionKey,omitempty"`
140140
// Filter tasks based on process definition keys

external-task_integration_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ func TestFetchAndLockIntegration(t *testing.T) {
3030
assert.NoError(t, err)
3131

3232
// wait processing StartInstance in camunda
33-
time.Sleep(time.Second * 10)
33+
time.Sleep(time.Second * 15)
3434

3535
tasks, err := client.ExternalTask.FetchAndLock(QueryFetchAndLock{
3636
WorkerId: "test-fetch-and-lock-integration",
3737
MaxTasks: 10,
38-
Topics: &[]QueryFetchAndLockTopic{
38+
Topics: []*QueryFetchAndLockTopic{
3939
{
4040
LockDuration: 1000,
4141
TopicName: "PrintHello",
@@ -53,7 +53,7 @@ func TestFetchAndLockIntegration(t *testing.T) {
5353
tasks, err = client.ExternalTask.FetchAndLock(QueryFetchAndLock{
5454
WorkerId: "test-fetch-and-lock-integration",
5555
MaxTasks: 10,
56-
Topics: &[]QueryFetchAndLockTopic{
56+
Topics: []*QueryFetchAndLockTopic{
5757
{
5858
LockDuration: 1000,
5959
TopicName: "PrintHello",

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/citilinkru/camunda-client-go/v2
1+
module github.com/citilinkru/camunda-client-go
22

33
go 1.14
44

history.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type ReqHistoryProcessInstanceQuery struct {
1212
// Filter by process instance id.
1313
ProcessInstanceId *string `json:"processInstanceId"`
1414
// Filter by a list of process instance ids. Must be a JSON array of Strings.
15-
ProcessInstanceIds *[]string `json:"processInstanceIds"`
15+
ProcessInstanceIds []string `json:"processInstanceIds"`
1616
// Filter by process instance business key.
1717
BusinessKey *string `json:"processInstanceBusinessKey"`
1818
// Filter by process instance business key that the parameter is a substring of.
@@ -25,10 +25,10 @@ type ReqHistoryProcessInstanceQuery struct {
2525
ProcessDefinitionKey *string `json:"processDefinitionKey"`
2626
// Filter by a list of process definition keys. A process instance must have one of the
2727
// given process definition keys. Must be a JSON array of Strings.
28-
ProcessDefinitionKeyIn *[]string `json:"processDefinitionKeyIn"`
28+
ProcessDefinitionKeyIn []string `json:"processDefinitionKeyIn"`
2929
// Exclude instances by a list of process definition keys. A process instance must not have one of the
3030
// given process definition keys. Must be a JSON array of Strings.
31-
ProcessDefinitionKeyNotIn *[]string `json:"processDefinitionKeyNotIn"`
31+
ProcessDefinitionKeyNotIn []string `json:"processDefinitionKeyNotIn"`
3232
// Filter by the name of the process definition the instances run on.
3333
ProcessDefinitionName *string `json:"processDefinitionName"`
3434
// Filter by process definition names that the parameter is a substring of.
@@ -75,21 +75,21 @@ type ReqHistoryProcessInstanceQuery struct {
7575
IncidentMessageLike *string `json:"incidentMessageLike"`
7676
// Filter by a list of tenant ids. A process instance must have one of the given tenant ids.
7777
// Must be a JSON array of Strings.
78-
TenantIdIn *[]string `json:"tenantIdIn"`
78+
TenantIdIn []string `json:"tenantIdIn"`
7979
// Only include process instances which belong to no tenant. Value may only be true, as false is the default behavior.
8080
WithoutTenantId *bool `json:"withoutTenantId"`
8181
// Filter by a list of activity ids. A process instance must currently wait in a leaf activity with one of the given activity ids.
82-
ActivityIdIn *[]string `json:"activityIdIn"`
82+
ActivityIdIn []string `json:"activityIdIn"`
8383
// Restrict to instance that executed an activity with one of given ids.
84-
ExecutedActivityIdIn *[]string `json:"executedActivityIdIn"`
84+
ExecutedActivityIdIn []string `json:"executedActivityIdIn"`
8585
// Restrict the query to all process instances that are top level process instances.
8686
RootProcessInstances *bool `json:"rootProcessInstances"`
8787
// Restrict the query to all process instances that are leaf instances. (i.e. don't have any sub instances)
8888
LeafProcessInstances *bool `json:"leafProcessInstances"`
8989
// Only include process instances which process definition has no tenant id.
9090
ProcessDefinitionWithoutTenantId *bool `json:"processDefinitionWithoutTenantId"`
9191
// A JSON array to only include process instances that have variables with certain values.
92-
Variables *[]ReqProcessVariableQuery `json:"variables"`
92+
Variables []ReqProcessVariableQuery `json:"variables"`
9393
// Match all variable names in this query case-insensitively.
9494
// If set to true variable-Name and variable-name are treated as equal.
9595
VariableNamesIgnoreCase *bool `json:"variableNamesIgnoreCase"`
@@ -100,11 +100,11 @@ type ReqHistoryProcessInstanceQuery struct {
100100
// A process instance matches a nested query if it fulfills at least one of the query's predicates.
101101
// With multiple nested queries, a process instance must fulfill at least one predicate of each query.
102102
// All process instance query properties can be used except for: sorting.
103-
OrQueries *[]ReqProcessInstanceQuery `json:"orQueries"`
103+
OrQueries []ReqProcessInstanceQuery `json:"orQueries"`
104104
// A JSON array of criteria to sort the result by.
105105
// Each element of the array is a JSON object that specifies one ordering.
106106
// The position in the array identifies the rank of an ordering, i.e., whether it is primary, secondary, etc.
107-
Sorting *[]ReqSort `json:"sorting"`
107+
Sorting []ReqSort `json:"sorting"`
108108
// Restrict to instance that was started before the given date.
109109
// 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.
110110
StartedBefore *string `json:"startedBefore"`
@@ -135,7 +135,7 @@ type ReqHistoryProcessInstanceQuery struct {
135135
// or an empty request body)
136136
type ReqHistoryDeleteProcessInstance struct {
137137
// A list process instance ids to delete.
138-
HistoricProcessInstanceIds *[]string `json:"historicProcessInstanceIds,omitempty"`
138+
HistoricProcessInstanceIds []string `json:"historicProcessInstanceIds,omitempty"`
139139
// A process instance query
140140
HistoricProcessInstanceQuery *ReqProcessInstanceQuery `json:"historicProcessInstanceQuery,omitempty"`
141141
// A string with delete reason.
@@ -149,15 +149,15 @@ type ReqHistoryVariableInstanceQuery struct {
149149
VariableNameLike *string `json:"variableNameLike"`
150150
VariableValue interface{} `json:"variableValue"`
151151
ProcessInstanceId *string `json:"processInstanceId"`
152-
ProcessInstanceIdIn *[]string `json:"processInstanceIdIn"`
152+
ProcessInstanceIdIn []string `json:"processInstanceIdIn"`
153153
ProcessDefinitionId *string `json:"process_definition_id"`
154-
ExecutionIdIn *[]string `json:"executionIdIn"`
154+
ExecutionIdIn []string `json:"executionIdIn"`
155155
CaseInstanceId *string `json:"caseInstanceId"`
156-
CaseExecutionIdIn *[]string `json:"caseExecutionIdIn"`
157-
CaseActivityIdIn *[]string `json:"caseActivityIdIn"`
158-
TaskIdIn *[]string `json:"taskIdIn"`
159-
ActivityInstanceIdIn *[]string `json:"activityInstanceIdIn"`
160-
TenantIdIn *[]string `json:"tenantIdIn"`
156+
CaseExecutionIdIn []string `json:"caseExecutionIdIn"`
157+
CaseActivityIdIn []string `json:"caseActivityIdIn"`
158+
TaskIdIn []string `json:"taskIdIn"`
159+
ActivityInstanceIdIn []string `json:"activityInstanceIdIn"`
160+
TenantIdIn []string `json:"tenantIdIn"`
161161
}
162162

163163
// ResHistoryProcessInstance a response object for process instance

process-definition.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type ReqStartInstance struct {
8888
CaseInstanceId *string `json:"caseInstanceId,omitempty"`
8989
// Optional. A JSON array of instructions that specify which activities to start the process instance at.
9090
// If this property is omitted, the process instance starts at its default blank start event
91-
StartInstructions *[]ReqStartInstructions `json:"startInstructions,omitempty"`
91+
StartInstructions []ReqStartInstructions `json:"startInstructions,omitempty"`
9292
// Skip execution listener invocation for activities that are started or ended as part of this request
9393
// Note: This option is currently only respected when start instructions are submitted via
9494
// the startInstructions property
@@ -109,7 +109,7 @@ type ReqRestartInstance struct {
109109
HistoricProcessInstanceQuery *string `json:"historicProcessInstanceQuery,omitempty"`
110110
// Optional. A JSON array of instructions that specify which activities to start the process instance at.
111111
// If this property is omitted, the process instance starts at its default blank start event
112-
StartInstructions *[]ReqStartInstructions `json:"startInstructions,omitempty"`
112+
StartInstructions []ReqStartInstructions `json:"startInstructions,omitempty"`
113113
// Skip execution listener invocation for activities that are started or ended as part of this request
114114
// Note: This option is currently only respected when start instructions are submitted via
115115
// the startInstructions property

0 commit comments

Comments
 (0)