Skip to content

Commit 17d4ad7

Browse files
authored
Merge pull request #33 from cschleiden/redis-backend
Add initial version of Redis backend
2 parents 851d897 + 42bedfe commit 17d4ad7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1687
-292
lines changed

.github/workflows/go.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ jobs:
2121
- name: Build
2222
run: go build -v ./...
2323

24+
- name: Start Redis
25+
uses: shogo82148/actions-setup-redis@v1
26+
with:
27+
auto-start: true
28+
redis-port: 6379
29+
redis-version: latest
30+
redis-conf: 'requirepass RedisPassw0rd'
31+
2432
- name: Tests
2533
run: |
2634
sudo /etc/init.d/mysql start

.vscode/launch.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
78
{
89
"name": "Current sample",
910
"type": "go",
@@ -53,5 +54,12 @@
5354
"mode": "debug",
5455
"program": "${workspaceFolder}/samples/subworkflow/subworkflow.go"
5556
},
57+
{
58+
"name": "Launch scale/worker sample",
59+
"type": "go",
60+
"request": "launch",
61+
"mode": "debug",
62+
"program": "${workspaceFolder}/samples/scale/worker/main.go"
63+
},
5664
]
5765
}

backend/backend.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package backend
33
import (
44
"context"
55

6+
core "github.com/cschleiden/go-workflows/internal/core"
67
"github.com/cschleiden/go-workflows/internal/history"
78
"github.com/cschleiden/go-workflows/internal/task"
89
"github.com/cschleiden/go-workflows/workflow"
@@ -21,13 +22,13 @@ type Backend interface {
2122
CreateWorkflowInstance(ctx context.Context, event history.WorkflowEvent) error
2223

2324
// CancelWorkflowInstance cancels a running workflow instance
24-
CancelWorkflowInstance(ctx context.Context, instance workflow.Instance) error
25+
CancelWorkflowInstance(ctx context.Context, instance *workflow.Instance, event *history.Event) error
2526

2627
// GetWorkflowInstanceState returns the state of the given workflow instance
27-
GetWorkflowInstanceState(ctx context.Context, instance workflow.Instance) (WorkflowState, error)
28+
GetWorkflowInstanceState(ctx context.Context, instance *workflow.Instance) (WorkflowState, error)
2829

2930
// GetWorkflowInstanceHistory returns the full workflow history for the given instance
30-
GetWorkflowInstanceHistory(ctx context.Context, instance workflow.Instance) ([]history.Event, error)
31+
GetWorkflowInstanceHistory(ctx context.Context, instance *workflow.Instance) ([]history.Event, error)
3132

3233
// SignalWorkflow signals a running workflow instance
3334
SignalWorkflow(ctx context.Context, instanceID string, event history.Event) error
@@ -36,22 +37,22 @@ type Backend interface {
3637
GetWorkflowTask(ctx context.Context) (*task.Workflow, error)
3738

3839
// ExtendWorkflowTask extends the lock of a workflow task
39-
ExtendWorkflowTask(ctx context.Context, instance workflow.Instance) error
40+
ExtendWorkflowTask(ctx context.Context, taskID string, instance *core.WorkflowInstance) error
4041

4142
// CompleteWorkflowTask checkpoints a workflow task retrieved using GetWorkflowTask
4243
//
4344
// This checkpoints the execution. events are new events from the last workflow execution
4445
// which will be added to the workflow instance history. workflowEvents are new events for the
4546
// completed or other workflow instances.
4647
CompleteWorkflowTask(
47-
ctx context.Context, instance workflow.Instance, state WorkflowState,
48+
ctx context.Context, taskID string, instance *workflow.Instance, state WorkflowState,
4849
executedEvents []history.Event, activityEvents []history.Event, workflowEvents []history.WorkflowEvent) error
4950

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

5354
// CompleteActivityTask completes a activity task retrieved using GetActivityTask
54-
CompleteActivityTask(ctx context.Context, instance workflow.Instance, activityID string, event history.Event) error
55+
CompleteActivityTask(ctx context.Context, instance *workflow.Instance, activityID string, event history.Event) error
5556

5657
// ExtendActivityTask extends the lock of an activity task
5758
ExtendActivityTask(ctx context.Context, activityID string) error

backend/mock_Backend.go

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

0 commit comments

Comments
 (0)