Skip to content

Commit

Permalink
add awaiting on external event, update dependencies (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuannh982 authored Feb 19, 2025
1 parent fda70e0 commit fd400e5
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docker/docker-compose-psql.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
postgres:
image: 'bitnami/postgresql:latest'
restart: always
restart: unless-stopped
environment:
POSTGRESQL_USERNAME: "user"
POSTGRESQL_PASSWORD: "123456"
Expand Down
27 changes: 14 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
module github.com/tuannh982/simple-workflow-go

go 1.22
go 1.23.0

toolchain go1.22.2
toolchain go1.23.6

require (
github.com/google/uuid v1.6.0
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
go.uber.org/zap v1.27.0
gorm.io/driver/postgres v1.5.9
gorm.io/driver/postgres v1.5.11
gorm.io/gorm v1.25.12
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.5.5 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.2 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/text v0.21.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.33.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/text v0.22.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
32 changes: 27 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,45 +1,65 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw=
github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
github.com/jackc/pgx/v5 v5.7.2 h1:mLoDLV6sonKlvjIEsV56SkWNCnuNv531l94GaIzO+XI=
github.com/jackc/pgx/v5 v5.7.2/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ=
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand All @@ -48,5 +68,7 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/postgres v1.5.9 h1:DkegyItji119OlcaLjqN11kHoUgZ/j13E0jkJZgD6A8=
gorm.io/driver/postgres v1.5.9/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI=
gorm.io/driver/postgres v1.5.11 h1:ubBVAfbKEUld/twyKZ0IYn9rSQh448EdelLYk9Mv314=
gorm.io/driver/postgres v1.5.11/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI=
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
40 changes: 40 additions & 0 deletions internal/workflow/event_promise.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package workflow

import "github.com/tuannh982/simple-workflow-go/pkg/utils/promise"

type EventPromise struct {
WorkflowRuntime *WorkflowRuntime
EventName string
Promise *promise.Promise[[]byte]
}

func NewEventPromise(runtime *WorkflowRuntime, eventName string) *EventPromise {
p := promise.NewPromise[[]byte]()
return &EventPromise{
WorkflowRuntime: runtime,
EventName: eventName,
Promise: p,
}
}

func (a *EventPromise) Await() ([]byte, error) {
for {
if a.Promise.IsDone() {
err := a.Promise.Error()
if a.Promise.Value() != nil {
return *a.Promise.Value(), nil
} else {
return nil, err
}
} else {
done, unExpectedErr := a.WorkflowRuntime.Step()
if unExpectedErr != nil {
panic(unExpectedErr)
}
if done {
break
}
}
}
panic(ErrControlledPanic)
}
29 changes: 29 additions & 0 deletions internal/workflow/workflow_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type WorkflowRuntime struct {
ActivityPromises map[int64]*UntypedActivityPromise
TimerCreatedEvents map[int64]*history.TimerCreated
TimerPromises map[int64]*TimerPromise
EventPromises map[string]map[int64]*EventPromise
// start
WorkflowExecutionStartedTimestamp int64
WorkflowExecutionStartedEvent *history.WorkflowExecutionStarted
Expand All @@ -57,6 +58,7 @@ func NewWorkflowRuntime(
ActivityPromises: make(map[int64]*UntypedActivityPromise),
TimerCreatedEvents: make(map[int64]*history.TimerCreated),
TimerPromises: make(map[int64]*TimerPromise),
EventPromises: make(map[string]map[int64]*EventPromise),
}
}

Expand Down Expand Up @@ -361,8 +363,35 @@ func (w *WorkflowRuntime) handleTimerFired(event *history.HistoryEvent) error {
}
}

/*
Event
*/

func (w *WorkflowRuntime) NewEventPromise(eventName string) *EventPromise {
taskScheduledID := w.nextSeqNo()
if w.EventPromises[eventName] != nil && w.EventPromises[eventName][taskScheduledID] != nil {
return w.EventPromises[eventName][taskScheduledID]
}
promise := NewEventPromise(w, eventName)
if w.EventPromises[eventName] == nil {
w.EventPromises[eventName] = make(map[int64]*EventPromise)
}
w.EventPromises[eventName][taskScheduledID] = promise
return promise
}

func (w *WorkflowRuntime) handleExternalEventReceived(event *history.HistoryEvent) error {
if e := event.ExternalEventReceived; e != nil {
// handle event promises
eventName := e.EventName
if w.EventPromises[eventName] != nil {
promises := w.EventPromises[eventName]
for _, promise := range promises {
promise.Promise.Resolve(&e.Input)
}
delete(w.EventPromises, eventName)
}
// handle callbacks
callbackRegistry := w.WorkflowExecutionContext.EventCallbacks
if callbacks, ok := callbackRegistry[e.EventName]; ok {
for _, callback := range callbacks {
Expand Down
6 changes: 6 additions & 0 deletions pkg/api/workflow/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@ func OnEvent(ctx context.Context, eventName string, callback func([]byte)) {
}
workflowCtx.EventCallbacks[eventName] = append(workflowCtx.EventCallbacks[eventName], callback)
}

func AwaitEvent(ctx context.Context, eventName string) ([]byte, error) {
workflowCtx := workflow.MustExtractWorkflowExecutionContext(ctx)
promise := workflowCtx.WorkflowRuntime.NewEventPromise(eventName)
return promise.Await()
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//go:build e2e
// +build e2e

package external_event
package await_external_event

import (
"context"
Expand Down Expand Up @@ -40,7 +40,7 @@ func Test(t *testing.T) {
WithBackend(be).
WithLogger(logger).
RegisterWorkflows(
ExternalEventWorkflow,
AwaitExternalEventWorkflow,
).
Build()
assert.NoError(t, err)
Expand All @@ -55,15 +55,15 @@ func Test(t *testing.T) {
uid, err := uuid.NewV6()
assert.NoError(t, err)
workflowID := fmt.Sprintf("e2e-external-event-workflow-%s", uid.String())
err = client.ScheduleWorkflow(ctx, be, ExternalEventWorkflow, &Void{}, client.WorkflowScheduleOptions{
err = client.ScheduleWorkflow(ctx, be, AwaitExternalEventWorkflow, &Void{}, client.WorkflowScheduleOptions{
WorkflowID: workflowID,
Version: "1",
})
assert.NoError(t, err)
time.Sleep(1 * time.Second)
err = client.SendWorkflowEvent(ctx, be, workflowID, HelloEventName, []byte(message))
assert.NoError(t, err)
wResult, wErr, err := client.AwaitWorkflowResult(ctx, be, ExternalEventWorkflow, workflowID)
wResult, wErr, err := client.AwaitWorkflowResult(ctx, be, AwaitExternalEventWorkflow, workflowID)
assert.NotNil(t, wResult)
assert.NoError(t, wErr)
//goland:noinspection GoDfaErrorMayBeNotNil
Expand Down
36 changes: 36 additions & 0 deletions test/e2e/psql/await_external_event/workflow.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//go:build e2e
// +build e2e

package await_external_event

import (
"context"
"fmt"
"github.com/tuannh982/simple-workflow-go/pkg/api/workflow"
)

type Void struct{}

type String struct {
Value string
}

func Activity1(ctx context.Context, input *String) (*String, error) {
return &String{
Value: fmt.Sprintf("Hello, %s!", input.Value),
}, nil
}

const HelloEventName = "hello"

func AwaitExternalEventWorkflow(ctx context.Context, _ *Void) (*String, error) {
message, err := workflow.AwaitEvent(ctx, HelloEventName)
if err != nil {
return nil, err
}
activity1Result, err := workflow.CallActivity(ctx, Activity1, &String{Value: string(message)}).Await()
if err != nil {
return nil, err
}
return &String{Value: activity1Result.Value}, nil
}
71 changes: 71 additions & 0 deletions test/e2e/psql/handle_external_event/handle_external_event_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//go:build e2e
// +build e2e

package handle_external_event

import (
"context"
"fmt"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/tuannh982/simple-workflow-go/pkg/api/client"
"github.com/tuannh982/simple-workflow-go/pkg/api/worker"
"github.com/tuannh982/simple-workflow-go/test/e2e/psql"
"go.uber.org/zap"
"testing"
"time"
)

func InitLogger() (*zap.Logger, error) {
return zap.NewProduction()
}

func Test(t *testing.T) {
ctx := context.Background()
logger, err := InitLogger()
assert.NoError(t, err)
be, err := psql.InitBackend(logger)
assert.NoError(t, err)
aw, err := worker.NewActivityWorkersBuilder().
WithName("[e2e test] ActivityWorker").
WithBackend(be).
WithLogger(logger).
RegisterActivities(
Activity1,
).
Build()
assert.NoError(t, err)
ww, err := worker.NewWorkflowWorkersBuilder().
WithName("[e2e test] WorkflowWorker").
WithBackend(be).
WithLogger(logger).
RegisterWorkflows(
HandleExternalEventWorkflow,
).
Build()
assert.NoError(t, err)
aw.Start(ctx)
defer aw.Stop(ctx)
ww.Start(ctx)
defer ww.Stop(ctx)
// mock results
message := "world"
expectedResult := fmt.Sprintf("Hello, %s!", message)
//
uid, err := uuid.NewV6()
assert.NoError(t, err)
workflowID := fmt.Sprintf("e2e-external-event-workflow-%s", uid.String())
err = client.ScheduleWorkflow(ctx, be, HandleExternalEventWorkflow, &Void{}, client.WorkflowScheduleOptions{
WorkflowID: workflowID,
Version: "1",
})
assert.NoError(t, err)
time.Sleep(1 * time.Second)
err = client.SendWorkflowEvent(ctx, be, workflowID, HelloEventName, []byte(message))
assert.NoError(t, err)
wResult, wErr, err := client.AwaitWorkflowResult(ctx, be, HandleExternalEventWorkflow, workflowID)
assert.NotNil(t, wResult)
assert.NoError(t, wErr)
//goland:noinspection GoDfaErrorMayBeNotNil
assert.Equal(t, expectedResult, wResult.Value)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//go:build e2e
// +build e2e

package external_event
package handle_external_event

import (
"context"
Expand All @@ -24,7 +24,7 @@ func Activity1(ctx context.Context, input *String) (*String, error) {

const HelloEventName = "hello"

func ExternalEventWorkflow(ctx context.Context, _ *Void) (*String, error) {
func HandleExternalEventWorkflow(ctx context.Context, _ *Void) (*String, error) {
message := ""
workflow.OnEvent(ctx, HelloEventName, func(bytes []byte) {
message = string(bytes)
Expand Down

0 comments on commit fd400e5

Please sign in to comment.