Skip to content

Commit 9d6310d

Browse files
committed
Merge branch 'main' into pr/lovromazgon/245
2 parents 27001d1 + fd3024e commit 9d6310d

File tree

168 files changed

+1025
-849
lines changed

Some content is hidden

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

168 files changed

+1025
-849
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ Create a `Client` instance then then call `CancelWorkflow` to cancel a workflow.
268268
Sub-workflows will be canceled if their parent workflow is canceled.
269269

270270
```go
271-
var c client.Client
271+
var c *client.Client
272272
err = c.CancelWorkflowInstance(context.Background(), workflowInstance)
273273
if err != nil {
274274
panic("could not cancel workflow")

activitytester/activitytester.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import (
44
"context"
55
"log/slog"
66

7+
"github.com/cschleiden/go-workflows/core"
78
"github.com/cschleiden/go-workflows/internal/activity"
8-
"github.com/cschleiden/go-workflows/internal/core"
99
)
1010

11+
// WithActivityTestState returns a context with an activity state attached that can be used for unit testing
12+
// activities.
1113
func WithActivityTestState(ctx context.Context, activityID, instanceID string, logger *slog.Logger) context.Context {
1214
if logger == nil {
1315
logger = slog.Default()

backend/backend.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import (
55
"errors"
66
"log/slog"
77

8-
"github.com/cschleiden/go-workflows/internal/contextpropagation"
9-
"github.com/cschleiden/go-workflows/internal/converter"
10-
core "github.com/cschleiden/go-workflows/internal/core"
11-
"github.com/cschleiden/go-workflows/internal/history"
12-
"github.com/cschleiden/go-workflows/internal/task"
13-
"github.com/cschleiden/go-workflows/metrics"
8+
"github.com/cschleiden/go-workflows/backend/converter"
9+
"github.com/cschleiden/go-workflows/backend/history"
10+
"github.com/cschleiden/go-workflows/backend/metrics"
11+
"github.com/cschleiden/go-workflows/core"
1412
"github.com/cschleiden/go-workflows/workflow"
1513
"go.opentelemetry.io/otel/trace"
1614
)
@@ -45,7 +43,7 @@ type Backend interface {
4543
SignalWorkflow(ctx context.Context, instanceID string, event *history.Event) error
4644

4745
// GetWorkflowTask returns a pending workflow task or nil if there are no pending workflow executions
48-
GetWorkflowTask(ctx context.Context) (*task.Workflow, error)
46+
GetWorkflowTask(ctx context.Context) (*WorkflowTask, error)
4947

5048
// ExtendWorkflowTask extends the lock of a workflow task
5149
ExtendWorkflowTask(ctx context.Context, taskID string, instance *core.WorkflowInstance) error
@@ -56,11 +54,11 @@ type Backend interface {
5654
// which will be added to the workflow instance history. workflowEvents are new events for the
5755
// completed or other workflow instances.
5856
CompleteWorkflowTask(
59-
ctx context.Context, task *task.Workflow, instance *workflow.Instance, state core.WorkflowInstanceState,
57+
ctx context.Context, task *WorkflowTask, instance *workflow.Instance, state core.WorkflowInstanceState,
6058
executedEvents, activityEvents, timerEvents []*history.Event, workflowEvents []history.WorkflowEvent) error
6159

6260
// GetActivityTask returns a pending activity task or nil if there are no pending activities
63-
GetActivityTask(ctx context.Context) (*task.Activity, error)
61+
GetActivityTask(ctx context.Context) (*ActivityTask, error)
6462

6563
// CompleteActivityTask completes an activity task retrieved using GetActivityTask
6664
CompleteActivityTask(ctx context.Context, instance *workflow.Instance, activityID string, event *history.Event) error
@@ -84,5 +82,5 @@ type Backend interface {
8482
Converter() converter.Converter
8583

8684
// ContextPropagators returns the configured context propagators for the backend
87-
ContextPropagators() []contextpropagation.ContextPropagator
85+
ContextPropagators() []workflow.ContextPropagator
8886
}

internal/converter/converter.go renamed to backend/converter/converter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package converter
22

33
import (
4-
"github.com/cschleiden/go-workflows/internal/payload"
4+
"github.com/cschleiden/go-workflows/backend/payload"
55
)
66

77
type Converter interface {

internal/converter/json.go renamed to backend/converter/json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package converter
33
import (
44
"encoding/json"
55

6-
"github.com/cschleiden/go-workflows/internal/payload"
6+
"github.com/cschleiden/go-workflows/backend/payload"
77
)
88

99
type jsonConverter struct{}

internal/history/activity_completed.go renamed to backend/history/activity_completed.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package history
22

3-
import "github.com/cschleiden/go-workflows/internal/payload"
3+
import "github.com/cschleiden/go-workflows/backend/payload"
44

55
type ActivityCompletedAttributes struct {
66
Result payload.Payload `json:"result,omitempty"`
File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package history
2+
3+
import (
4+
"github.com/cschleiden/go-workflows/backend/metadata"
5+
"github.com/cschleiden/go-workflows/backend/payload"
6+
)
7+
8+
type ActivityScheduledAttributes struct {
9+
Name string `json:"name,omitempty"`
10+
11+
Inputs []payload.Payload `json:"inputs,omitempty"`
12+
13+
Metadata *metadata.WorkflowMetadata `json:"metadata,omitempty"`
14+
}

internal/history/grouping.go renamed to backend/history/grouping.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package history
22

3-
import "github.com/cschleiden/go-workflows/internal/core"
3+
import "github.com/cschleiden/go-workflows/core"
44

55
func EventsByWorkflowInstance(events []WorkflowEvent) map[core.WorkflowInstance][]WorkflowEvent {
66
groupedEvents := make(map[core.WorkflowInstance][]WorkflowEvent)

internal/history/grouping_test.go renamed to backend/history/grouping_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"testing"
55
"time"
66

7-
"github.com/cschleiden/go-workflows/internal/core"
7+
"github.com/cschleiden/go-workflows/core"
88
"github.com/google/uuid"
99
"github.com/stretchr/testify/require"
1010
)

0 commit comments

Comments
 (0)