Skip to content

Commit 2e6fb88

Browse files
authored
Merge branch 'master' into caution-side-effect
2 parents 4459f97 + f8bfb87 commit 2e6fb88

26 files changed

+516
-171
lines changed

go.mod

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ require (
1313
github.com/opentracing/opentracing-go v1.1.0
1414
github.com/pborman/uuid v0.0.0-20160209185913-a97ce2ca70fa
1515
github.com/robfig/cron v1.2.0
16-
github.com/shirou/gopsutil v3.21.11+incompatible
1716
github.com/stretchr/testify v1.9.0
1817
github.com/uber-go/tally v3.3.15+incompatible
1918
github.com/uber/cadence-idl v0.0.0-20240723221048-0482c040f91d
@@ -35,7 +34,6 @@ require (
3534
github.com/beorn7/perks v1.0.1 // indirect
3635
github.com/cespare/xxhash/v2 v2.1.1 // indirect
3736
github.com/davecgh/go-spew v1.1.1 // indirect
38-
github.com/go-ole/go-ole v1.2.6 // indirect
3937
github.com/gogo/googleapis v1.3.2 // indirect
4038
github.com/gogo/status v1.1.0 // indirect
4139
github.com/golang/protobuf v1.5.3 // indirect
@@ -47,11 +45,8 @@ require (
4745
github.com/prometheus/common v0.26.0 // indirect
4846
github.com/prometheus/procfs v0.6.0 // indirect
4947
github.com/stretchr/objx v0.5.2 // indirect
50-
github.com/tklauser/go-sysconf v0.3.11 // indirect
51-
github.com/tklauser/numcpus v0.6.0 // indirect
5248
github.com/uber-go/mapdecode v1.0.0 // indirect
5349
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
54-
github.com/yusufpapurcu/wmi v1.2.3 // indirect
5550
go.uber.org/dig v1.10.0 // indirect
5651
go.uber.org/fx v1.13.1 // indirect
5752
go.uber.org/net/metrics v1.3.0 // indirect

go.sum

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb
4949
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
5050
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
5151
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
52-
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
53-
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
5452
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
5553
github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
5654
github.com/gogo/googleapis v1.3.2 h1:kX1es4djPJrsDhY7aZKJy7aZasdcB5oSOEphMjSB53c=
@@ -180,8 +178,6 @@ github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfm
180178
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
181179
github.com/samuel/go-thrift v0.0.0-20191111193933-5165175b40af h1:EiWVfh8mr40yFZEui2oF0d45KgH48PkB2H0Z0GANvSI=
182180
github.com/samuel/go-thrift v0.0.0-20191111193933-5165175b40af/go.mod h1:Vrkh1pnjV9Bl8c3P9zH0/D4NlOHWP5d4/hF4YTULaec=
183-
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
184-
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
185181
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
186182
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
187183
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
@@ -199,10 +195,6 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
199195
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
200196
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
201197
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
202-
github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM=
203-
github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI=
204-
github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms=
205-
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4=
206198
github.com/uber-common/bark v1.2.1/go.mod h1:g0ZuPcD7XiExKHynr93Q742G/sbrdVQkghrqLGOoFuY=
207199
github.com/uber-go/mapdecode v1.0.0 h1:euUEFM9KnuCa1OBixz1xM+FIXmpixyay5DLymceOVrU=
208200
github.com/uber-go/mapdecode v1.0.0/go.mod h1:b5nP15FwXTgpjTjeA9A2uTHXV5UJCl4arwKpP0FP1Hw=
@@ -223,8 +215,6 @@ github.com/uber/tchannel-go v1.32.1/go.mod h1:yT2EUp6YperZ0Tb/jwDX9gVEeiSG74r/L3
223215
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
224216
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
225217
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
226-
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
227-
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
228218
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
229219
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
230220
go.uber.org/atomic v1.5.1/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
@@ -317,7 +307,6 @@ golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5h
317307
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
318308
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
319309
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
320-
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
321310
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
322311
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
323312
golang.org/x/sys v0.0.0-20200117145432-59e60aa80a0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -332,7 +321,6 @@ golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7w
332321
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
333322
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
334323
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
335-
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
336324
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
337325
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
338326
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

internal/activity_task_handler_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ import (
2727
"testing"
2828
"time"
2929

30+
"go.uber.org/cadence/internal/common/testlogger"
31+
3032
"github.com/jonboulle/clockwork"
3133

3234
"github.com/golang/mock/gomock"
3335
"github.com/opentracing/opentracing-go"
3436
"github.com/pborman/uuid"
3537
"github.com/stretchr/testify/assert"
3638
"github.com/stretchr/testify/require"
37-
"go.uber.org/zap/zaptest"
3839

3940
"go.uber.org/cadence/.gen/go/cadence/workflowservicetest"
4041
s "go.uber.org/cadence/.gen/go/shared"
@@ -57,7 +58,7 @@ func TestActivityTaskHandler_Execute_deadline(t *testing.T) {
5758

5859
for i, d := range deadlineTests {
5960
t.Run(fmt.Sprintf("testIndex: %v, testDetails: %v", i, d), func(t *testing.T) {
60-
logger := zaptest.NewLogger(t)
61+
logger := testlogger.NewZap(t)
6162
a := &testActivityDeadline{logger: logger}
6263
registry := newRegistry()
6364
registry.addActivityWithLock(a.ActivityType().Name, a)
@@ -101,7 +102,7 @@ func TestActivityTaskHandler_Execute_deadline(t *testing.T) {
101102
}
102103

103104
func TestActivityTaskHandler_Execute_worker_stop(t *testing.T) {
104-
logger := zaptest.NewLogger(t)
105+
logger := testlogger.NewZap(t)
105106

106107
a := &testActivityDeadline{logger: logger}
107108
registry := newRegistry()
@@ -150,7 +151,7 @@ func TestActivityTaskHandler_Execute_worker_stop(t *testing.T) {
150151
}
151152

152153
func TestActivityTaskHandler_Execute_with_propagators(t *testing.T) {
153-
logger := zaptest.NewLogger(t)
154+
logger := testlogger.NewZap(t)
154155

155156
now := time.Now()
156157

@@ -208,7 +209,7 @@ func TestActivityTaskHandler_Execute_with_propagators(t *testing.T) {
208209
}
209210

210211
func TestActivityTaskHandler_Execute_with_propagator_failure(t *testing.T) {
211-
logger := zaptest.NewLogger(t)
212+
logger := testlogger.NewZap(t)
212213

213214
now := time.Now()
214215

@@ -254,7 +255,7 @@ func TestActivityTaskHandler_Execute_with_propagator_failure(t *testing.T) {
254255
}
255256

256257
func TestActivityTaskHandler_Execute_with_auto_heartbeat(t *testing.T) {
257-
logger := zaptest.NewLogger(t)
258+
logger := testlogger.NewZap(t)
258259

259260
now := time.Now()
260261

internal/activity_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ import (
2424
"context"
2525
"testing"
2626

27+
"go.uber.org/cadence/internal/common/testlogger"
28+
2729
"github.com/golang/mock/gomock"
2830
"github.com/stretchr/testify/require"
2931
"github.com/stretchr/testify/suite"
3032
"go.uber.org/yarpc"
3133
"go.uber.org/zap"
32-
"go.uber.org/zap/zaptest"
3334

3435
"go.uber.org/cadence/.gen/go/cadence/workflowservicetest"
3536
"go.uber.org/cadence/.gen/go/shared"
@@ -56,7 +57,7 @@ func TestActivityTestSuite(t *testing.T) {
5657
func (s *activityTestSuite) SetupTest() {
5758
s.mockCtrl = gomock.NewController(s.T())
5859
s.service = workflowservicetest.NewMockClient(s.mockCtrl)
59-
s.logger = zaptest.NewLogger(s.T())
60+
s.logger = testlogger.NewZap(s.T())
6061
}
6162

6263
func (s *activityTestSuite) TearDownTest() {

internal/auto_heartbeater_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ import (
2626
"testing"
2727
"time"
2828

29+
"go.uber.org/cadence/internal/common/testlogger"
30+
2931
"github.com/jonboulle/clockwork"
3032
"github.com/stretchr/testify/assert"
3133
"github.com/stretchr/testify/require"
32-
"go.uber.org/zap/zaptest"
3334

3435
"go.uber.org/cadence/.gen/go/shared"
3536
"go.uber.org/cadence/internal/common"
@@ -51,7 +52,7 @@ func TestAutoHearbeater_Run(t *testing.T) {
5152
t.Run("worker stop channel", func(t *testing.T) {
5253
stopCh := make(chan struct{})
5354
invoker := &MockServiceInvoker{}
54-
logger := zaptest.NewLogger(t)
55+
logger := testlogger.NewZap(t)
5556
clock := clockwork.NewFakeClock()
5657
hearbeater := newHeartbeater(stopCh, invoker, logger, clock, activityType, workflowExecution)
5758

@@ -62,7 +63,7 @@ func TestAutoHearbeater_Run(t *testing.T) {
6263
t.Run("context done", func(t *testing.T) {
6364
stopCh := make(chan struct{})
6465
invoker := &MockServiceInvoker{}
65-
logger := zaptest.NewLogger(t)
66+
logger := testlogger.NewZap(t)
6667
clock := clockwork.NewFakeClock()
6768
hearbeater := newHeartbeater(stopCh, invoker, logger, clock, activityType, workflowExecution)
6869

@@ -75,7 +76,7 @@ func TestAutoHearbeater_Run(t *testing.T) {
7576
stopCh := make(chan struct{})
7677
invoker := &MockServiceInvoker{}
7778
invoker.EXPECT().BackgroundHeartbeat().Return(nil).Once()
78-
logger := zaptest.NewLogger(t)
79+
logger := testlogger.NewZap(t)
7980
clock := clockwork.NewFakeClock()
8081
hearbeater := newHeartbeater(stopCh, invoker, logger, clock, activityType, workflowExecution)
8182

@@ -98,7 +99,7 @@ func TestAutoHearbeater_Run(t *testing.T) {
9899
stopCh := make(chan struct{})
99100
invoker := &MockServiceInvoker{}
100101
invoker.EXPECT().BackgroundHeartbeat().Return(assert.AnError).Once()
101-
logger := zaptest.NewLogger(t)
102+
logger := testlogger.NewZap(t)
102103
clock := clockwork.NewFakeClock()
103104
hearbeater := newHeartbeater(stopCh, invoker, logger, clock, activityType, workflowExecution)
104105

internal/common/convert.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,17 @@ func QueryResultTypePtr(t s.QueryResultType) *s.QueryResultType {
9595
func PtrOf[T any](v T) *T {
9696
return &v
9797
}
98+
99+
// ValueFromPtr returns the value from a pointer.
100+
func ValueFromPtr[T any](v *T) T {
101+
if v == nil {
102+
return Zero[T]()
103+
}
104+
return *v
105+
}
106+
107+
// Zero returns the zero value of a type by return type.
108+
func Zero[T any]() T {
109+
var zero T
110+
return zero
111+
}

internal/common/convert_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,20 @@ func TestCeilHelpers(t *testing.T) {
5555
assert.Equal(t, int32(2), Int32Ceil(1.1))
5656
assert.Equal(t, int64(2), Int64Ceil(1.1))
5757
}
58+
59+
func TestValueFromPtr(t *testing.T) {
60+
assert.Equal(t, "a", ValueFromPtr(PtrOf("a")))
61+
assert.Equal(t, 1, ValueFromPtr(PtrOf(1)))
62+
assert.Equal(t, int32(1), ValueFromPtr(PtrOf(int32(1))))
63+
assert.Equal(t, int64(1), ValueFromPtr(PtrOf(int64(1))))
64+
assert.Equal(t, 1.1, ValueFromPtr(PtrOf(1.1)))
65+
assert.Equal(t, true, ValueFromPtr(PtrOf(true)))
66+
assert.Equal(t, []string{"a"}, ValueFromPtr(PtrOf([]string{"a"})))
67+
assert.Equal(t, "" /* default value */, ValueFromPtr((*string)(nil)))
68+
}
69+
70+
func TestZero(t *testing.T) {
71+
assert.Equal(t, "", Zero[string]())
72+
assert.Equal(t, 0, Zero[int]())
73+
assert.Equal(t, (*int)(nil), Zero[*int]())
74+
}

internal/common/metrics/constants.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,6 @@ const (
110110
ReplaySkippedCounter = CadenceMetricsPrefix + "replay-skipped"
111111
ReplayLatency = CadenceMetricsPrefix + "replay-latency"
112112

113-
NumCPUCores = CadenceMetricsPrefix + "num-cpu-cores"
114-
CPUPercentage = CadenceMetricsPrefix + "cpu-percentage"
115-
TotalMemory = CadenceMetricsPrefix + "total-memory"
116-
MemoryUsedHeap = CadenceMetricsPrefix + "memory-used-heap"
117-
MemoryUsedStack = CadenceMetricsPrefix + "memory-used-stack"
118-
NumGoRoutines = CadenceMetricsPrefix + "num-go-routines"
119-
120113
EstimatedHistorySize = CadenceMetricsPrefix + "estimated-history-size"
121114
ServerSideHistorySize = CadenceMetricsPrefix + "server-side-history-size"
122115
ConcurrentTaskQuota = CadenceMetricsPrefix + "concurrent-task-quota"

0 commit comments

Comments
 (0)