Skip to content

Commit 9c173f0

Browse files
committed
Merge branch 'master' into v1.2.x
2 parents 112b33a + 08b284a commit 9c173f0

File tree

24 files changed

+1364
-310
lines changed

24 files changed

+1364
-310
lines changed

.buildkite/pipeline.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ steps:
2121
run: unit-test
2222
config: docker/buildkite/docker-compose.yml
2323

24+
- label: ":golangci-lint: validate code is clean"
25+
agents:
26+
queue: "workers"
27+
docker: "*"
28+
command: "./scripts/golint.sh"
29+
artifact_paths: [ ]
30+
retry:
31+
automatic:
32+
limit: 1
33+
plugins:
34+
- docker-compose#v3.0.0:
35+
run: unit-test
36+
config: docker/buildkite/docker-compose.yml
37+
2438
- label: ":golang: integration-test-sticky-off"
2539
agents:
2640
queue: "workers"

Makefile

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ endif
5050
# ====================================
5151

5252
# note that vars that do not yet exist are empty, so stick to BUILD/BIN and probably nothing else.
53-
$(BUILD)/lint: $(BUILD)/fmt $(BUILD)/dummy # lint will fail if fmt or dummy fails, so run them first
54-
$(BUILD)/dummy: $(BUILD)/fmt # do a build after fmt-ing
53+
$(BUILD)/lint: $(BUILD)/fmt # lint will fail if fmt (more generally, build) fails, so run it first
5554
$(BUILD)/fmt: $(BUILD)/copyright # formatting must occur only after all other go-file-modifications are done
5655
$(BUILD)/copyright: $(BUILD)/codegen # must add copyright to generated code
57-
$(BUILD)/codegen: $(BUILD)/thrift # thrift is currently the only codegen, but this way it's easier to extend
56+
$(BUILD)/codegen: $(BUILD)/thrift $(BUILD)/generate
57+
$(BUILD)/generate: $(BUILD)/thrift # go generate broadly requires compile-able code, which needs thrift
5858
$(BUILD)/thrift: $(BUILD)/go_mod_check
5959
$(BUILD)/go_mod_check: | $(BUILD) $(BIN)
6060

@@ -157,14 +157,13 @@ $(BIN)/errcheck: internal/tools/go.mod
157157
$(BIN)/goveralls: internal/tools/go.mod
158158
$(call go_build_tool,github.com/mattn/goveralls)
159159

160+
$(BIN)/mockery: internal/tools/go.mod
161+
$(call go_build_tool,github.com/vektra/mockery/v2,mockery)
162+
160163
# copyright header checker/writer. only requires stdlib, so no other dependencies are needed.
161164
$(BIN)/copyright: internal/cmd/tools/copyright/licensegen.go
162165
go build -mod=readonly -o $@ ./internal/cmd/tools/copyright/licensegen.go
163166

164-
# dummy binary that ensures most/all packages build, without needing to wait for tests.
165-
$(BUILD)/dummy: $(ALL_SRC) $(BUILD)/go_mod_check
166-
go build -mod=readonly -o $@ internal/cmd/dummy/dummy.go
167-
168167
# ensures mod files are in sync for critical packages
169168
$(BUILD)/go_mod_check: go.mod internal/tools/go.mod
170169
$Q # ensure both have the same apache/thrift replacement
@@ -185,7 +184,7 @@ $(if $(wildcard THRIFT_FILES),,$(error idls/ submodule must exist, or build will
185184
endef
186185

187186
# codegen is done when thrift is done (it's just a naming-convenience, $(BUILD)/thrift would be fine too)
188-
$(BUILD)/codegen: $(BUILD)/thrift | $(BUILD)
187+
$(BUILD)/codegen: | $(BUILD)
189188
$Q touch $@
190189

191190
THRIFT_FILES := idls/thrift/cadence.thrift idls/thrift/shadower.thrift
@@ -216,6 +215,12 @@ $(THRIFT_GEN): $(THRIFT_FILES) $(BIN)/thriftrw $(BIN)/thriftrw-plugin-yarpc
216215
$(subst $(BUILD),idls/thrift,$@)
217216
$Q touch $@
218217

218+
# mockery is quite noisy so it's worth being kinda precise with the files.
219+
# this needs to be both the files defining the generate command, AND the files that define the interfaces.
220+
$(BUILD)/generate: client/client.go encoded/encoded.go internal/internal_workflow_client.go $(BIN)/mockery
221+
$Q $(BIN_PATH) go generate ./...
222+
$Q touch $@
223+
219224
# ====================================
220225
# other intermediates
221226
# ====================================
@@ -268,7 +273,10 @@ $Q +$(MAKE) --no-print-directory $(addprefix $(BUILD)/,$(1))
268273
endef
269274

270275
.PHONY: build
271-
build: $(BUILD)/dummy ## ensure all packages build
276+
build: $(BUILD)/fmt ## ensure all packages build
277+
go build ./...
278+
$Q # caution: some errors are reported on stdout for some reason
279+
go test -exec true ./... >/dev/null
272280

273281
.PHONY: lint
274282
# useful to actually re-run to get output again.
@@ -294,8 +302,16 @@ staticcheck: $(BIN)/staticcheck $(BUILD)/fmt ## (re)run staticcheck
294302
errcheck: $(BIN)/errcheck $(BUILD)/fmt ## (re)run errcheck
295303
$(BIN)/errcheck ./...
296304

305+
.PHONY: generate
306+
generate: $(BUILD)/generate ## run go-generate
307+
308+
.PHONY: tidy
309+
tidy:
310+
go mod tidy
311+
cd internal/tools; go mod tidy
312+
297313
.PHONY: all
298-
all: $(BUILD)/lint ## refresh codegen, lint, and ensure the dummy binary builds, if necessary
314+
all: $(BUILD)/lint ## refresh codegen, lint, and ensure everything builds, whatever is necessary
299315

300316
.PHONY: clean
301317
clean:

client/client.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
// THE SOFTWARE.
2020

21+
// when adding any, make sure you update the files that it checks in the makefile
22+
//go:generate mockery --srcpkg . --name Client --output ../mocks --boilerplate-file ../LICENSE
23+
//go:generate mockery --srcpkg . --name DomainClient --output ../mocks --boilerplate-file ../LICENSE
24+
//go:generate mockery --srcpkg go.uber.org/cadence/internal --name HistoryEventIterator --output ../mocks --boilerplate-file ../LICENSE
25+
//go:generate mockery --srcpkg go.uber.org/cadence/internal --name WorkflowRun --output ../mocks --boilerplate-file ../LICENSE
26+
2127
// Package client contains functions to create Cadence clients used to communicate to Cadence service.
2228
//
2329
// Use these to perform CRUD on domains and start or query workflow executions.
@@ -98,6 +104,15 @@ type (
98104
// - InternalServiceError
99105
StartWorkflow(ctx context.Context, options StartWorkflowOptions, workflowFunc interface{}, args ...interface{}) (*workflow.Execution, error)
100106

107+
// StartWorkflowAsync behaves like StartWorkflow except that the request is first queued and then processed asynchronously.
108+
// See StartWorkflow for parameter details.
109+
// The returned AsyncWorkflowExecution doesn't contain run ID, because the workflow hasn't started yet.
110+
// The errors it can return:
111+
// - EntityNotExistsError, if domain does not exists
112+
// - BadRequestError
113+
// - InternalServiceError
114+
StartWorkflowAsync(ctx context.Context, options StartWorkflowOptions, workflow interface{}, args ...interface{}) (*workflow.ExecutionAsync, error)
115+
101116
// ExecuteWorkflow starts a workflow execution and return a WorkflowRun instance and error
102117
// The user can use this to start using a function or workflow type name.
103118
// Either by
@@ -163,6 +178,15 @@ type (
163178
SignalWithStartWorkflow(ctx context.Context, workflowID string, signalName string, signalArg interface{},
164179
options StartWorkflowOptions, workflowFunc interface{}, workflowArgs ...interface{}) (*workflow.Execution, error)
165180

181+
// SignalWithStartWorkflowAsync behaves like SignalWithStartWorkflow except that the request is first queued and then processed asynchronously.
182+
// See SignalWithStartWorkflow for parameter details.
183+
// The errors it can return:
184+
// - EntityNotExistsError, if domain does not exist
185+
// - BadRequestError
186+
// - InternalServiceError
187+
SignalWithStartWorkflowAsync(ctx context.Context, workflowID string, signalName string, signalArg interface{},
188+
options StartWorkflowOptions, workflow interface{}, workflowArgs ...interface{}) (*workflow.ExecutionAsync, error)
189+
166190
// CancelWorkflow cancels a workflow in execution
167191
// - workflow ID of the workflow.
168192
// - runID can be default(empty string). if empty string then it will pick the running execution of that workflow ID.

codecov.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ coverage:
1919
if_ci_failed: ignore # require the CI to pass before setting the status
2020
patch:
2121
default:
22-
informational: true
22+
target: 85% # specify the target coverage for each commit status
23+
# option: "auto" (compare against parent commit or pull request base)
24+
# option: "X%" a static target percentage to hit
25+
threshold: 0% # allow the coverage drop by x% before marking as failure
2326
comment:
2427
layout: "header, files, footer"
2528
hide_project_coverage: false

docker/buildkite/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ RUN mkdir -p /go/src/go.uber.org/cadence
44
WORKDIR /go/src/go.uber.org/cadence
55

66
ADD go.mod go.sum /go/src/go.uber.org/cadence/
7+
8+
# allow git-status and similar to work
9+
RUN git config --global --add safe.directory /go/src/go.uber.org/cadence
710
RUN GO111MODULE=on go mod download

encoded/encoded.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
// THE SOFTWARE.
2020

21+
//go:generate mockery --srcpkg go.uber.org/cadence/internal --name Value --output ../mocks --boilerplate-file ../LICENSE
22+
2123
// Package encoded contains wrappers that are used for binary payloads deserialization.
2224
package encoded
2325

go.sum

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
9191
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
9292
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
9393
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
94-
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
94+
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
9595
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
9696
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
9797
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
@@ -206,8 +206,6 @@ github.com/uber-go/mapdecode v1.0.0/go.mod h1:b5nP15FwXTgpjTjeA9A2uTHXV5UJCl4arw
206206
github.com/uber-go/tally v3.3.12+incompatible/go.mod h1:YDTIBxdXyOU/sCWilKB4bgyufu1cEi0jdVnRdxvjnmU=
207207
github.com/uber-go/tally v3.3.15+incompatible h1:9hLSgNBP28CjIaDmAuRTq9qV+UZY+9PcvAkXO4nNMwg=
208208
github.com/uber-go/tally v3.3.15+incompatible/go.mod h1:YDTIBxdXyOU/sCWilKB4bgyufu1cEi0jdVnRdxvjnmU=
209-
github.com/uber/cadence-idl v0.0.0-20230905165949-03586319b849 h1:j3bfADG1t35Lt4rNRpc9AuQ3l2cGw2Ao25Qt6rDamgc=
210-
github.com/uber/cadence-idl v0.0.0-20230905165949-03586319b849/go.mod h1:oyUK7GCNCRHCCyWyzifSzXpVrRYVBbAMHAzF5dXiKws=
211209
github.com/uber/cadence-idl v0.0.0-20240212223805-34b4519b2709 h1:1u+kMB6p8P9fjK6jk3QHAl8PxLyNjO9/TMXoPOVr1O8=
212210
github.com/uber/cadence-idl v0.0.0-20240212223805-34b4519b2709/go.mod h1:oyUK7GCNCRHCCyWyzifSzXpVrRYVBbAMHAzF5dXiKws=
213211
github.com/uber/jaeger-client-go v2.22.1+incompatible h1:NHcubEkVbahf9t3p75TOCR83gdUHXjRJvjoBh1yACsM=
@@ -299,8 +297,6 @@ golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAG
299297
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
300298
golang.org/x/oauth2 v0.1.0 h1:isLCZuhj4v+tYv7eskaN4v/TM+A1begWWgyVJDdl1+Y=
301299
golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A=
302-
golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ=
303-
golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM=
304300
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
305301
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
306302
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

internal/client.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ type (
9393
// subjected to change in the future.
9494
StartWorkflow(ctx context.Context, options StartWorkflowOptions, workflow interface{}, args ...interface{}) (*WorkflowExecution, error)
9595

96+
// StartWorkflowAsync behaves like StartWorkflow except that the request is first queued and then processed asynchronously.
97+
// See StartWorkflow for parameter details.
98+
// The returned AsyncWorkflowExecution doesn't contain run ID, because the workflow hasn't started yet.
99+
// The errors it can return:
100+
// - EntityNotExistsError, if domain does not exists
101+
// - BadRequestError
102+
// - InternalServiceError
103+
StartWorkflowAsync(ctx context.Context, options StartWorkflowOptions, workflow interface{}, args ...interface{}) (*WorkflowExecutionAsync, error)
104+
96105
// ExecuteWorkflow starts a workflow execution and return a WorkflowRun instance and error
97106
// The user can use this to start using a function or workflow type name.
98107
// Either by
@@ -160,6 +169,15 @@ type (
160169
SignalWithStartWorkflow(ctx context.Context, workflowID string, signalName string, signalArg interface{},
161170
options StartWorkflowOptions, workflow interface{}, workflowArgs ...interface{}) (*WorkflowExecution, error)
162171

172+
// SignalWithStartWorkflowAsync behaves like SignalWithStartWorkflow except that the request is first queued and then processed asynchronously.
173+
// See SignalWithStartWorkflow for parameter details.
174+
// The errors it can return:
175+
// - EntityNotExistsError, if domain does not exist
176+
// - BadRequestError
177+
// - InternalServiceError
178+
SignalWithStartWorkflowAsync(ctx context.Context, workflowID string, signalName string, signalArg interface{},
179+
options StartWorkflowOptions, workflow interface{}, workflowArgs ...interface{}) (*WorkflowExecutionAsync, error)
180+
163181
// CancelWorkflow cancels a workflow in execution
164182
// - workflow ID of the workflow.
165183
// - runID can be default(empty string). if empty string then it will pick the running execution of that workflow ID.

internal/cmd/dummy/dummy.go

Lines changed: 0 additions & 35 deletions
This file was deleted.

internal/common/metrics/constants.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,21 @@ package metrics
2222

2323
// Workflow Creation metrics
2424
const (
25-
CadenceMetricsPrefix = "cadence-"
26-
WorkflowStartCounter = CadenceMetricsPrefix + "workflow-start"
27-
WorkflowCompletedCounter = CadenceMetricsPrefix + "workflow-completed"
28-
WorkflowCanceledCounter = CadenceMetricsPrefix + "workflow-canceled"
29-
WorkflowFailedCounter = CadenceMetricsPrefix + "workflow-failed"
30-
WorkflowContinueAsNewCounter = CadenceMetricsPrefix + "workflow-continue-as-new"
31-
WorkflowEndToEndLatency = CadenceMetricsPrefix + "workflow-endtoend-latency" // measure workflow execution from start to close
32-
WorkflowGetHistoryCounter = CadenceMetricsPrefix + "workflow-get-history-total"
33-
WorkflowGetHistoryFailedCounter = CadenceMetricsPrefix + "workflow-get-history-failed"
34-
WorkflowGetHistorySucceedCounter = CadenceMetricsPrefix + "workflow-get-history-succeed"
35-
WorkflowGetHistoryLatency = CadenceMetricsPrefix + "workflow-get-history-latency"
36-
WorkflowSignalWithStartCounter = CadenceMetricsPrefix + "workflow-signal-with-start"
37-
DecisionTimeoutCounter = CadenceMetricsPrefix + "decision-timeout"
25+
CadenceMetricsPrefix = "cadence-"
26+
WorkflowStartCounter = CadenceMetricsPrefix + "workflow-start"
27+
WorkflowStartAsyncCounter = CadenceMetricsPrefix + "workflow-start-async"
28+
WorkflowCompletedCounter = CadenceMetricsPrefix + "workflow-completed"
29+
WorkflowCanceledCounter = CadenceMetricsPrefix + "workflow-canceled"
30+
WorkflowFailedCounter = CadenceMetricsPrefix + "workflow-failed"
31+
WorkflowContinueAsNewCounter = CadenceMetricsPrefix + "workflow-continue-as-new"
32+
WorkflowEndToEndLatency = CadenceMetricsPrefix + "workflow-endtoend-latency" // measure workflow execution from start to close
33+
WorkflowGetHistoryCounter = CadenceMetricsPrefix + "workflow-get-history-total"
34+
WorkflowGetHistoryFailedCounter = CadenceMetricsPrefix + "workflow-get-history-failed"
35+
WorkflowGetHistorySucceedCounter = CadenceMetricsPrefix + "workflow-get-history-succeed"
36+
WorkflowGetHistoryLatency = CadenceMetricsPrefix + "workflow-get-history-latency"
37+
WorkflowSignalWithStartCounter = CadenceMetricsPrefix + "workflow-signal-with-start"
38+
WorkflowSignalWithStartAsyncCounter = CadenceMetricsPrefix + "workflow-signal-with-start-async"
39+
DecisionTimeoutCounter = CadenceMetricsPrefix + "decision-timeout"
3840

3941
DecisionPollCounter = CadenceMetricsPrefix + "decision-poll-total"
4042
DecisionPollFailedCounter = CadenceMetricsPrefix + "decision-poll-failed"

0 commit comments

Comments
 (0)