Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add additional message hanlder #334

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions aggregatedpool/workflow.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package aggregatedpool

import (
"fmt"
"sync/atomic"
"time"

Expand Down Expand Up @@ -149,6 +150,10 @@ func (wp *Workflow) OnWorkflowTaskStarted(t time.Duration) {
wp.pipeline = wp.pipeline[1:]

if msg.IsCommand() {
if msg.UndefinedResponse() {
panic(fmt.Sprintf("undefined response: %s", msg.Command.(*internal.UndefinedResponse).Message))
}

err = wp.handleMessage(msg)
}

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/google/uuid v1.3.0
github.com/roadrunner-server/endure/v2 v2.2.0
github.com/roadrunner-server/errors v1.2.0
github.com/roadrunner-server/sdk/v4 v4.1.0
github.com/roadrunner-server/sdk/v4 v4.2.0
github.com/stretchr/testify v1.8.1
github.com/uber-go/tally/v4 v4.1.6
go.temporal.io/api v1.17.0
Expand Down Expand Up @@ -40,7 +40,7 @@ require (
github.com/prometheus/common v0.39.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/roadrunner-server/goridge/v3 v3.6.2 // indirect
github.com/roadrunner-server/tcplisten v1.2.1 // indirect
github.com/roadrunner-server/tcplisten v1.3.0 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
Expand All @@ -51,7 +51,7 @@ require (
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/net v0.6.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
Expand Down
11 changes: 6 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,10 @@ github.com/roadrunner-server/errors v1.2.0 h1:qBmNXt8Iex9QnYTjCkbJKsBZu2EtYkQCM0
github.com/roadrunner-server/errors v1.2.0/go.mod h1:z0ECxZp/dDa5RahtMcy4mBIavVxiZ9vwE5kByl7kFtY=
github.com/roadrunner-server/goridge/v3 v3.6.2 h1:LH5HXfCygDp05KnOaXpa4fqVPWTsH7V3lfvPtMwFU3k=
github.com/roadrunner-server/goridge/v3 v3.6.2/go.mod h1:3B95k/wM5GGAD0h2hZlJagS9PlTDGs5jh8MpZYC12vA=
github.com/roadrunner-server/sdk/v4 v4.1.0 h1:akICxF9GQOHggvHW01Try5QiRmr2IrCN0RYWHyGdjDQ=
github.com/roadrunner-server/sdk/v4 v4.1.0/go.mod h1:aIzXmg8DZBJ4Tbtvihp/s6VH4e2oSdivOqm/8V+HuUc=
github.com/roadrunner-server/tcplisten v1.2.1 h1:9hVVMlCRvMPewnJCnfSe/kKAqn2ZOF3wHy+ji0M/NKU=
github.com/roadrunner-server/tcplisten v1.2.1/go.mod h1:TRJLGwIruiJ7QhmGVRgJFY5Ch72mPoLhLAxuxLnavpU=
github.com/roadrunner-server/sdk/v4 v4.2.0 h1:hqNlqJV2MXZ8DF1wJnouUdV/55Hae6VL37fVXT1aIr8=
github.com/roadrunner-server/sdk/v4 v4.2.0/go.mod h1:aIzXmg8DZBJ4Tbtvihp/s6VH4e2oSdivOqm/8V+HuUc=
github.com/roadrunner-server/tcplisten v1.3.0 h1:VDd6IbP8oIjm5vKvMVozeZgeHgOcoP0XYLOyOqcZHCY=
github.com/roadrunner-server/tcplisten v1.3.0/go.mod h1:VR6Ob5am0oEuLMOeLiVvQxG9ShykAEgrlvZddX8EfoU=
github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
Expand Down Expand Up @@ -831,8 +831,9 @@ golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfS
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/net v0.6.0 h1:L4ZwwTvKW9gr0ZMS1yrHD9GZhIuVjOBBnaKH+SPQK0Q=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down
24 changes: 19 additions & 5 deletions internal/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const (
signalExternalWorkflowCommand = "SignalExternalWorkflow"
cancelExternalWorkflowCommand = "CancelExternalWorkflow"

undefinedResponse = "UndefinedResponse"

cancelCommand = "Cancel"
panicCommand = "Panic"
)
Expand All @@ -59,16 +61,12 @@ type Context struct {
type Message struct {
// ID contains ID of the command, response or error.
ID uint64 `json:"id"`

// Command of the message in unmarshalled form. Pointer.
Command any `json:"command,omitempty"`

// Failure associated with command id.
Failure *failure.Failure `json:"failure,omitempty"`

// Payloads contains message specific payloads in binary format.
Payloads *commonpb.Payloads `json:"payloads,omitempty"`

// Header
Header *commonpb.Header `json:"header,omitempty"`
}
Expand All @@ -83,6 +81,14 @@ func (msg *Message) IsCommand() bool {
return msg.Command != nil
}

func (msg *Message) UndefinedResponse() bool {
if _, ok := msg.Command.(*UndefinedResponse); ok {
return true
}

return false
}

func (msg *Message) Reset() {
msg.ID = 0
msg.Command = nil
Expand Down Expand Up @@ -251,6 +257,11 @@ type CancelExternalWorkflow struct {
RunID string `json:"runID"`
}

// UndefinedResponse indicates that we should panic the workflow
type UndefinedResponse struct {
Message string `json:"message"`
}

// Cancel one or multiple internal promises (activities, local activities, timers, child workflows).
type Cancel struct {
// CommandIDs to be canceled.
Expand Down Expand Up @@ -471,7 +482,10 @@ func InitCommand(name string) (any, error) {
case panicCommand:
return &Panic{}, nil

case undefinedResponse:
return &UndefinedResponse{}, nil

default:
return nil, errors.E(op, errors.Errorf("undefined command name: %s", name))
return nil, errors.E(op, errors.Errorf("undefined command name: %s, possible outdated RoadRunner version", name))
}
}
2 changes: 1 addition & 1 deletion proto/api
Submodule api updated 36 files
+2 −1 .github/CODEOWNERS
+1 −1 Makefile
+2 −2 temporal/api/batch/v1/message.proto
+7 −19 temporal/api/command/v1/message.proto
+2 −2 temporal/api/common/v1/message.proto
+2 −2 temporal/api/enums/v1/batch_operation.proto
+3 −8 temporal/api/enums/v1/command_type.proto
+3 −2 temporal/api/enums/v1/common.proto
+8 −8 temporal/api/enums/v1/event_type.proto
+25 −2 temporal/api/enums/v1/failed_cause.proto
+2 −2 temporal/api/enums/v1/namespace.proto
+2 −2 temporal/api/enums/v1/query.proto
+2 −2 temporal/api/enums/v1/reset.proto
+2 −2 temporal/api/enums/v1/schedule.proto
+2 −2 temporal/api/enums/v1/task_queue.proto
+24 −8 temporal/api/enums/v1/update.proto
+2 −2 temporal/api/enums/v1/workflow.proto
+2 −2 temporal/api/errordetails/v1/message.proto
+2 −2 temporal/api/failure/v1/message.proto
+2 −2 temporal/api/filter/v1/message.proto
+48 −21 temporal/api/history/v1/message.proto
+0 −87 temporal/api/interaction/v1/message.proto
+4 −2 temporal/api/namespace/v1/message.proto
+5 −2 temporal/api/operatorservice/v1/request_response.proto
+2 −2 temporal/api/operatorservice/v1/service.proto
+29 −11 temporal/api/protocol/v1/message.proto
+2 −2 temporal/api/query/v1/message.proto
+2 −2 temporal/api/replication/v1/message.proto
+2 −2 temporal/api/schedule/v1/message.proto
+63 −0 temporal/api/sdk/v1/task_complete_metadata.proto
+2 −2 temporal/api/taskqueue/v1/message.proto
+111 −0 temporal/api/update/v1/message.proto
+2 −2 temporal/api/version/v1/message.proto
+2 −2 temporal/api/workflow/v1/message.proto
+59 −30 temporal/api/workflowservice/v1/request_response.proto
+4 −4 temporal/api/workflowservice/v1/service.proto
2 changes: 1 addition & 1 deletion proto/protocol/v1/protocol.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.