Skip to content

Commit db1eaf2

Browse files
authored
remove SignalChannel (#480)
1 parent 7636327 commit db1eaf2

File tree

4 files changed

+5
-80
lines changed

4 files changed

+5
-80
lines changed

internal/internal_workflow.go

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ type (
162162
workflowID string
163163
childPolicy ChildWorkflowPolicy
164164
waitForCancellation bool
165-
signalChannels map[string]SignalChannel
165+
signalChannels map[string]Channel
166166
queryHandlers map[string]func([]byte) ([]byte, error)
167167
workflowIDReusePolicy WorkflowIDReusePolicy
168168
dataConverter encoded.DataConverter
@@ -490,27 +490,6 @@ func getState(ctx Context) *coroutineState {
490490
return state
491491
}
492492

493-
func (c *channelImpl) ReceiveEncodedValue(ctx Context) (value encoded.Value, more bool) {
494-
var blob []byte
495-
more = c.Receive(ctx, &blob)
496-
value = newEncodedValue(blob, c.dataConverter)
497-
return
498-
}
499-
500-
func (c *channelImpl) ReceiveEncodedValueAsync() (value encoded.Value, ok bool) {
501-
var blob []byte
502-
ok = c.ReceiveAsync(&blob)
503-
value = newEncodedValue(blob, c.dataConverter)
504-
return
505-
}
506-
507-
func (c *channelImpl) ReceiveEncodedValueAsyncWithMoreFlag() (value encoded.Value, ok bool, more bool) {
508-
var blob []byte
509-
ok, more = c.ReceiveAsyncWithMoreFlag(&blob)
510-
value = newEncodedValue(blob, c.dataConverter)
511-
return
512-
}
513-
514493
func (c *channelImpl) Receive(ctx Context, valuePtr interface{}) (more bool) {
515494
state := getState(ctx)
516495
hasResult := false
@@ -1089,7 +1068,7 @@ func setWorkflowEnvOptionsIfNotExist(ctx Context) Context {
10891068
if options != nil {
10901069
newOptions = *options
10911070
} else {
1092-
newOptions.signalChannels = make(map[string]SignalChannel)
1071+
newOptions.signalChannels = make(map[string]Channel)
10931072
newOptions.queryHandlers = make(map[string]func([]byte) ([]byte, error))
10941073
}
10951074
if newOptions.dataConverter == nil {
@@ -1107,11 +1086,11 @@ func getDataConverterFromWorkflowContext(ctx Context) encoded.DataConverter {
11071086
}
11081087

11091088
// getSignalChannel finds the assosciated channel for the signal.
1110-
func (w *workflowOptions) getSignalChannel(ctx Context, signalName string) SignalChannel {
1089+
func (w *workflowOptions) getSignalChannel(ctx Context, signalName string) Channel {
11111090
if ch, ok := w.signalChannels[signalName]; ok {
11121091
return ch
11131092
}
1114-
ch := NewBufferedChannel(ctx, defaultSignalChannelSize).(SignalChannel)
1093+
ch := NewBufferedChannel(ctx, defaultSignalChannelSize)
11151094
w.signalChannels[signalName] = ch
11161095
return ch
11171096
}

internal/internal_workflow_testsuite_test.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,30 +1702,6 @@ func (s *WorkflowTestSuiteUnitTest) Test_Channel() {
17021702
s.True(ok)
17031703
}
17041704

1705-
func (s *WorkflowTestSuiteUnitTest) Test_SignalChannel() {
1706-
workflowFn := func(ctx Context) error {
1707-
signalCh := GetSignalChannel(ctx, "test-signal")
1708-
encodedValue, _ := signalCh.ReceiveEncodedValue(ctx)
1709-
1710-
var signal string
1711-
err := encodedValue.Get(&signal)
1712-
return err
1713-
}
1714-
1715-
RegisterWorkflow(workflowFn)
1716-
env := s.NewTestWorkflowEnvironment()
1717-
1718-
env.RegisterDelayedCallback(func() {
1719-
env.SignalWorkflow("test-signal", 123)
1720-
}, time.Minute)
1721-
1722-
env.ExecuteWorkflow(workflowFn)
1723-
1724-
s.True(env.IsWorkflowCompleted())
1725-
s.Error(env.GetWorkflowError())
1726-
s.Contains(env.GetWorkflowError().Error(), "decode")
1727-
}
1728-
17291705
func (s *WorkflowTestSuiteUnitTest) Test_ContextMisuse() {
17301706
workflowFn := func(ctx Context) error {
17311707
ch := NewChannel(ctx)

internal/workflow.go

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,6 @@ type (
7070
Close()
7171
}
7272

73-
// SignalChannel extends from Channel. It adds the ability to deal with corrupted signal data. Signal is sent to
74-
// Cadence server as binary blob. When workflow try to receive signal data as strongly typed value, the Channel will
75-
// try to decode that binary blob into that strongly typed value pointer. If that data is corrupted and cannot be
76-
// decoded, the Receive call will panic which will block the workflow. That might not be expected behavior. This
77-
// SignalChannel adds new methods so that workflow could receive signal as encoded.Value, and then extract that strongly
78-
// typed value from encoded.Value. If the decoding fails, the encoded.Value will return error instead of panic.
79-
SignalChannel interface {
80-
Channel
81-
82-
// ReceiveEncodedValue blocks until it receives a value, and then return that value as encoded.Value.
83-
// Returns false when Channel is closed.
84-
ReceiveEncodedValue(ctx Context) (value encoded.Value, more bool)
85-
86-
// ReceiveEncodedValueAsync try to receive from Channel without blocking. If there is data available from the
87-
// Channel, it returns the data as encoded.Value and true. Otherwise, it returns nil and false immediately.
88-
ReceiveEncodedValueAsync() (value encoded.Value, ok bool)
89-
90-
// ReceiveEncodedValueAsyncWithMoreFlag is same as ReceiveEncodedValueAsync with extra return value more to
91-
// indicate if there could be more value from the Channel. The more is false when Channel is closed.
92-
ReceiveEncodedValueAsyncWithMoreFlag() (value encoded.Value, ok bool, more bool)
93-
}
94-
9573
// Selector must be used instead of native go select by workflow code.
9674
// Use workflow.NewSelector(ctx) method to create a Selector instance.
9775
Selector interface {
@@ -791,7 +769,7 @@ func WithDataConverter(ctx Context, dc encoded.DataConverter) Context {
791769
}
792770

793771
// GetSignalChannel returns channel corresponding to the signal name.
794-
func GetSignalChannel(ctx Context, signalName string) SignalChannel {
772+
func GetSignalChannel(ctx Context, signalName string) Channel {
795773
return getWorkflowEnvOptions(ctx).getSignalChannel(ctx, signalName)
796774
}
797775

workflow/deterministic_wrappers.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ type (
3232
// Use workflow.NewChannel(ctx) method to create Channel instance.
3333
Channel = internal.Channel
3434

35-
// SignalChannel extends from Channel. It adds the ability to deal with corrupted signal data. Signal is sent to
36-
// Cadence server as binary blob. When workflow try to receive signal data as strongly typed value, the Channel will
37-
// try to decode that binary blob into that strongly typed value pointer. If that data is corrupted and cannot be
38-
// decoded, the Receive call will panic which will block the workflow. That might not be expected behavior. This
39-
// SignalChannel adds new methods so that workflow could receive signal as encoded.Value, and then extract that strongly
40-
// typed value from encoded.Value. If the decoding fails, the encoded.Value will return error instead of panic.
41-
SignalChannel = internal.SignalChannel
42-
4335
// Selector must be used instead of native go select by workflow code.
4436
// Use workflow.NewSelector(ctx) method to create a Selector instance.
4537
Selector = internal.Selector

0 commit comments

Comments
 (0)