Skip to content

Commit 3d3f3d7

Browse files
committed
Update references
1 parent 9321779 commit 3d3f3d7

File tree

9 files changed

+38
-39
lines changed

9 files changed

+38
-39
lines changed

backend/backend.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
//go:generate mockery --name=Backend --inpackage
1212
type Backend interface {
1313
// CreateWorkflowInstance creates a new workflow instance
14-
CreateWorkflowInstance(ctx context.Context, event core.WorkflowEvent) error
14+
CreateWorkflowInstance(ctx context.Context, event history.WorkflowEvent) error
1515

1616
// CancelWorkflowInstance cancels a running workflow instance
1717
CancelWorkflowInstance(ctx context.Context, instance core.WorkflowInstance) error
@@ -30,7 +30,7 @@ type Backend interface {
3030
// This checkpoints the execution. events are new events from the last workflow execution
3131
// which will be added to the workflow instance history. workflowEvents are new events for the
3232
// completed or other workflow instances.
33-
CompleteWorkflowTask(ctx context.Context, instance core.WorkflowInstance, executedEvents []history.Event, workflowEvents []core.WorkflowEvent) error
33+
CompleteWorkflowTask(ctx context.Context, instance core.WorkflowInstance, executedEvents []history.Event, workflowEvents []history.WorkflowEvent) error
3434

3535
// GetActivityTask returns a pending activity task or nil if there are no pending activities
3636
GetActivityTask(ctx context.Context) (*task.Activity, error)

backend/mock_Backend.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/mysql/mysql.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type mysqlBackend struct {
5656
}
5757

5858
// CreateWorkflowInstance creates a new workflow instance
59-
func (b *mysqlBackend) CreateWorkflowInstance(ctx context.Context, m core.WorkflowEvent) error {
59+
func (b *mysqlBackend) CreateWorkflowInstance(ctx context.Context, m history.WorkflowEvent) error {
6060
tx, err := b.db.BeginTx(ctx, nil)
6161
if err != nil {
6262
return errors.Wrap(err, "could not start transaction")
@@ -360,7 +360,7 @@ func (b *mysqlBackend) CompleteWorkflowTask(
360360
ctx context.Context,
361361
instance core.WorkflowInstance,
362362
executedEvents []history.Event,
363-
workflowEvents []core.WorkflowEvent,
363+
workflowEvents []history.WorkflowEvent,
364364
) error {
365365
tx, err := b.db.BeginTx(ctx, &sql.TxOptions{
366366
Isolation: sql.LevelReadCommitted,

backend/sqlite/sqlite.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type sqliteBackend struct {
5757
options backend.Options
5858
}
5959

60-
func (sb *sqliteBackend) CreateWorkflowInstance(ctx context.Context, m core.WorkflowEvent) error {
60+
func (sb *sqliteBackend) CreateWorkflowInstance(ctx context.Context, m history.WorkflowEvent) error {
6161
tx, err := sb.db.BeginTx(ctx, nil)
6262
if err != nil {
6363
return errors.Wrap(err, "could not start transaction")
@@ -267,13 +267,13 @@ func (sb *sqliteBackend) GetWorkflowTask(ctx context.Context) (*task.Workflow, e
267267
return t, nil
268268
}
269269

270-
// CompleteWorkflowTask(ctx context.Context, instance core.WorkflowInstance, executedEvents []history.Event, workflowEvents []core.WorkflowEvent) error
270+
// CompleteWorkflowTask(ctx context.Context, instance core.WorkflowInstance, executedEvents []history.Event, workflowEvents []history.WorkflowEvent) error
271271

272272
func (sb *sqliteBackend) CompleteWorkflowTask(
273273
ctx context.Context,
274274
instance core.WorkflowInstance,
275275
executedEvents []history.Event,
276-
workflowEvents []core.WorkflowEvent,
276+
workflowEvents []history.WorkflowEvent,
277277
) error {
278278
tx, err := sb.db.BeginTx(ctx, nil)
279279
if err != nil {

backend/test/backend.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (s *BackendTestSuite) Test_GetActivityTask_ReturnNilWhenTimeout() {
7070
func (s *BackendTestSuite) Test_CreateWorkflowInstance_DoesNotError() {
7171
ctx := context.Background()
7272

73-
err := s.b.CreateWorkflowInstance(ctx, core.WorkflowEvent{
73+
err := s.b.CreateWorkflowInstance(ctx, history.WorkflowEvent{
7474
WorkflowInstance: core.NewWorkflowInstance(uuid.NewString(), uuid.NewString()),
7575
HistoryEvent: history.NewHistoryEvent(time.Now(), history.EventType_WorkflowExecutionStarted, &history.ExecutionStartedAttributes{}),
7676
})
@@ -81,7 +81,7 @@ func (s *BackendTestSuite) Test_GetWorkflowTask_ReturnsTask() {
8181
ctx := context.Background()
8282

8383
wfi := core.NewWorkflowInstance(uuid.NewString(), uuid.NewString())
84-
err := s.b.CreateWorkflowInstance(ctx, core.WorkflowEvent{
84+
err := s.b.CreateWorkflowInstance(ctx, history.WorkflowEvent{
8585
WorkflowInstance: wfi,
8686
HistoryEvent: history.NewHistoryEvent(time.Now(), history.EventType_WorkflowExecutionStarted, &history.ExecutionStartedAttributes{}),
8787
})
@@ -98,7 +98,7 @@ func (s *BackendTestSuite) Test_GetWorkflowTask_LocksTask() {
9898
ctx := context.Background()
9999

100100
wfi := core.NewWorkflowInstance(uuid.NewString(), uuid.NewString())
101-
err := s.b.CreateWorkflowInstance(ctx, core.WorkflowEvent{
101+
err := s.b.CreateWorkflowInstance(ctx, history.WorkflowEvent{
102102
WorkflowInstance: wfi,
103103
HistoryEvent: history.NewHistoryEvent(time.Now(), history.EventType_WorkflowExecutionStarted, &history.ExecutionStartedAttributes{}),
104104
})
@@ -123,13 +123,13 @@ func (s *BackendTestSuite) Test_CompleteWorkflowTask_ReturnsErrorIfNotLocked() {
123123
ctx := context.Background()
124124

125125
wfi := core.NewWorkflowInstance(uuid.NewString(), uuid.NewString())
126-
err := s.b.CreateWorkflowInstance(ctx, core.WorkflowEvent{
126+
err := s.b.CreateWorkflowInstance(ctx, history.WorkflowEvent{
127127
WorkflowInstance: wfi,
128128
HistoryEvent: history.NewHistoryEvent(time.Now(), history.EventType_WorkflowExecutionStarted, &history.ExecutionStartedAttributes{}),
129129
})
130130
s.NoError(err)
131131

132-
err = s.b.CompleteWorkflowTask(ctx, wfi, []history.Event{}, []core.WorkflowEvent{})
132+
err = s.b.CompleteWorkflowTask(ctx, wfi, []history.Event{}, []history.WorkflowEvent{})
133133

134134
s.Error(err)
135135
}
@@ -142,7 +142,7 @@ func (s *BackendTestSuite) Test_CompleteWorkflowTask_AddsNewEventsToHistory() {
142142
activityCompletedEvent := history.NewHistoryEvent(time.Now(), history.EventType_ActivityCompleted, &history.ActivityCompletedAttributes{}, history.ScheduleEventID(1))
143143

144144
wfi := core.NewWorkflowInstance(uuid.NewString(), uuid.NewString())
145-
err := s.b.CreateWorkflowInstance(ctx, core.WorkflowEvent{
145+
err := s.b.CreateWorkflowInstance(ctx, history.WorkflowEvent{
146146
WorkflowInstance: wfi,
147147
HistoryEvent: startedEvent,
148148
})
@@ -160,7 +160,7 @@ func (s *BackendTestSuite) Test_CompleteWorkflowTask_AddsNewEventsToHistory() {
160160
taskFinishedEvent,
161161
}
162162

163-
workflowEvents := []core.WorkflowEvent{
163+
workflowEvents := []history.WorkflowEvent{
164164
{
165165
WorkflowInstance: wfi,
166166
HistoryEvent: activityCompletedEvent,

client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (c *client) CreateWorkflowInstance(ctx context.Context, options WorkflowIns
5353

5454
wfi := core.NewWorkflowInstance(options.InstanceID, uuid.NewString())
5555

56-
startMessage := &core.WorkflowEvent{
56+
startMessage := &history.WorkflowEvent{
5757
WorkflowInstance: wfi,
5858
HistoryEvent: startedEvent,
5959
}

internal/tester/tester.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ type workflowTester struct {
100100
clock *clock.Mock
101101

102102
timers []*testTimer
103-
callbacks chan func() *core.WorkflowEvent
103+
callbacks chan func() *history.WorkflowEvent
104104

105105
subWorkflowListener func(core.WorkflowInstance, string)
106106

@@ -136,7 +136,7 @@ func NewWorkflowTester(wf workflow.Workflow) WorkflowTester {
136136
clock: clock,
137137

138138
timers: make([]*testTimer, 0),
139-
callbacks: make(chan func() *core.WorkflowEvent, 1024),
139+
callbacks: make(chan func() *history.WorkflowEvent, 1024),
140140
}
141141

142142
// Always register the workflow under test
@@ -333,7 +333,7 @@ func (wt *workflowTester) SignalWorkflowInstance(wfi core.WorkflowInstance, name
333333
panic("Could not convert signal value to string" + err.Error())
334334
}
335335

336-
wt.callbacks <- func() *core.WorkflowEvent {
336+
wt.callbacks <- func() *history.WorkflowEvent {
337337
e := history.NewHistoryEvent(
338338
wt.clock.Now(),
339339
history.EventType_SignalReceived,
@@ -343,7 +343,7 @@ func (wt *workflowTester) SignalWorkflowInstance(wfi core.WorkflowInstance, name
343343
},
344344
)
345345

346-
return &core.WorkflowEvent{
346+
return &history.WorkflowEvent{
347347
WorkflowInstance: wfi,
348348
HistoryEvent: e,
349349
}
@@ -436,7 +436,7 @@ func (wt *workflowTester) scheduleActivity(wfi core.WorkflowInstance, event hist
436436
})
437437
}
438438

439-
wt.callbacks <- func() *core.WorkflowEvent {
439+
wt.callbacks <- func() *history.WorkflowEvent {
440440
var ne history.Event
441441

442442
if activityErr != nil {
@@ -459,28 +459,28 @@ func (wt *workflowTester) scheduleActivity(wfi core.WorkflowInstance, event hist
459459
)
460460
}
461461

462-
return &core.WorkflowEvent{
462+
return &history.WorkflowEvent{
463463
WorkflowInstance: wfi,
464464
HistoryEvent: ne,
465465
}
466466
}
467467
}()
468468
}
469469

470-
func (wt *workflowTester) scheduleTimer(event core.WorkflowEvent) {
470+
func (wt *workflowTester) scheduleTimer(event history.WorkflowEvent) {
471471
e := event.HistoryEvent.Attributes.(*history.TimerFiredAttributes)
472472

473473
wt.timers = append(wt.timers, &testTimer{
474474
At: e.At,
475475
Callback: func() {
476-
wt.callbacks <- func() *core.WorkflowEvent {
476+
wt.callbacks <- func() *history.WorkflowEvent {
477477
return &event
478478
}
479479
},
480480
})
481481
}
482482

483-
func (wt *workflowTester) scheduleSubWorkflow(event core.WorkflowEvent) {
483+
func (wt *workflowTester) scheduleSubWorkflow(event history.WorkflowEvent) {
484484
a := event.HistoryEvent.Attributes.(*history.ExecutionStartedAttributes)
485485

486486
// TODO: Right location to call handler?
@@ -542,7 +542,7 @@ func (wt *workflowTester) scheduleSubWorkflow(event core.WorkflowEvent) {
542542
)
543543
}
544544

545-
wt.callbacks <- func() *core.WorkflowEvent {
545+
wt.callbacks <- func() *history.WorkflowEvent {
546546
// Ideally we'd execute the same command here, but for now duplicate the code
547547
var he history.Event
548548

@@ -566,7 +566,7 @@ func (wt *workflowTester) scheduleSubWorkflow(event core.WorkflowEvent) {
566566
)
567567
}
568568

569-
return &core.WorkflowEvent{
569+
return &history.WorkflowEvent{
570570
WorkflowInstance: event.WorkflowInstance.ParentInstance(),
571571
HistoryEvent: he,
572572
}

internal/worker/workflow.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
"github.com/benbjohnson/clock"
1010
"github.com/cschleiden/go-workflows/backend"
11-
"github.com/cschleiden/go-workflows/core"
1211
"github.com/cschleiden/go-workflows/core/task"
1312
"github.com/cschleiden/go-workflows/internal/history"
1413
"github.com/cschleiden/go-workflows/internal/workflow"
@@ -129,7 +128,7 @@ func (ww *workflowWorker) handle(ctx context.Context, t *task.Workflow) {
129128
}
130129
}
131130

132-
func (ww *workflowWorker) handleTask(ctx context.Context, t *task.Workflow) ([]history.Event, []core.WorkflowEvent, error) {
131+
func (ww *workflowWorker) handleTask(ctx context.Context, t *task.Workflow) ([]history.Event, []history.WorkflowEvent, error) {
133132
executor, err := ww.getExecutor(ctx, t)
134133
if err != nil {
135134
return nil, nil, err

internal/workflow/executor.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
)
2121

2222
type WorkflowExecutor interface {
23-
ExecuteTask(ctx context.Context, t *task.Workflow) ([]history.Event, []core.WorkflowEvent, error)
23+
ExecuteTask(ctx context.Context, t *task.Workflow) ([]history.Event, []history.WorkflowEvent, error)
2424

2525
Close()
2626
}
@@ -51,7 +51,7 @@ func NewExecutor(registry *Registry, instance core.WorkflowInstance, clock clock
5151
}, nil
5252
}
5353

54-
func (e *executor) ExecuteTask(ctx context.Context, t *task.Workflow) ([]history.Event, []core.WorkflowEvent, error) {
54+
func (e *executor) ExecuteTask(ctx context.Context, t *task.Workflow) ([]history.Event, []history.WorkflowEvent, error) {
5555
if t.Kind == task.Continuation {
5656
// Check if the current state matches the backend's history state
5757
newestHistoryEvent := t.History[len(t.History)-1]
@@ -330,12 +330,12 @@ func (e *executor) workflowCompleted(result payload.Payload, err error) error {
330330
return nil
331331
}
332332

333-
func (e *executor) processCommands(ctx context.Context, t *task.Workflow) ([]history.Event, []core.WorkflowEvent, error) {
333+
func (e *executor) processCommands(ctx context.Context, t *task.Workflow) ([]history.Event, []history.WorkflowEvent, error) {
334334
instance := t.WorkflowInstance
335335
commands := e.workflowState.commands
336336

337337
newEvents := make([]history.Event, 0)
338-
workflowEvents := make([]core.WorkflowEvent, 0)
338+
workflowEvents := make([]history.WorkflowEvent, 0)
339339

340340
for _, c := range commands {
341341
// TODO: Move to state machine?
@@ -373,7 +373,7 @@ func (e *executor) processCommands(ctx context.Context, t *task.Workflow) ([]his
373373
))
374374

375375
// Send message to new workflow instance
376-
workflowEvents = append(workflowEvents, core.WorkflowEvent{
376+
workflowEvents = append(workflowEvents, history.WorkflowEvent{
377377
WorkflowInstance: subWorkflowInstance,
378378
HistoryEvent: history.NewHistoryEvent(
379379
e.clock.Now(),
@@ -410,7 +410,7 @@ func (e *executor) processCommands(ctx context.Context, t *task.Workflow) ([]his
410410
))
411411

412412
// Create timer_fired event which will become visible in the future
413-
workflowEvents = append(workflowEvents, core.WorkflowEvent{
413+
workflowEvents = append(workflowEvents, history.WorkflowEvent{
414414
WorkflowInstance: instance,
415415
HistoryEvent: history.NewHistoryEvent(
416416
e.clock.Now(),
@@ -463,7 +463,7 @@ func (e *executor) processCommands(ctx context.Context, t *task.Workflow) ([]his
463463
)
464464
}
465465

466-
workflowEvents = append(workflowEvents, core.WorkflowEvent{
466+
workflowEvents = append(workflowEvents, history.WorkflowEvent{
467467
WorkflowInstance: instance.ParentInstance(),
468468
HistoryEvent: historyEvent,
469469
})

0 commit comments

Comments
 (0)