forked from cschleiden/go-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backend.go
41 lines (32 loc) · 1.28 KB
/
backend.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package diag
import (
"context"
"time"
"github.com/paveliak/go-workflows/backend"
"github.com/paveliak/go-workflows/internal/core"
)
// json: serialization in this file needs to be kept in sync with client.ts in the web app
type WorkflowInstanceRef struct {
Instance *core.WorkflowInstance `json:"instance,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
State core.WorkflowInstanceState `json:"state"`
}
type Event struct {
ID string `json:"id,omitempty"`
SequenceID int64 `json:"sequence_id,omitempty"`
Type string `json:"type,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
ScheduleEventID int64 `json:"schedule_event_id,omitempty"`
Attributes interface{} `json:"attributes,omitempty"`
VisibleAt *time.Time `json:"visible_at,omitempty"`
}
type WorkflowInstanceInfo struct {
*WorkflowInstanceRef
History []*Event `json:"history,omitempty"`
}
type Backend interface {
backend.Backend
GetWorkflowInstance(ctx context.Context, instanceID string) (*WorkflowInstanceRef, error)
GetWorkflowInstances(ctx context.Context, afterInstanceID string, count int) ([]*WorkflowInstanceRef, error)
}