-
Notifications
You must be signed in to change notification settings - Fork 2
/
types.go
80 lines (68 loc) · 2.84 KB
/
types.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package workflow
import (
"log"
"net/url"
"github.com/rs/zerolog"
"github.com/khulnasoft-lab/go-application-framework/pkg/analytics"
"github.com/khulnasoft-lab/go-application-framework/pkg/configuration"
"github.com/khulnasoft-lab/go-application-framework/pkg/networking"
"github.com/khulnasoft-lab/go-application-framework/pkg/ui"
)
//go:generate $GOPATH/bin/mockgen -source=types.go -destination ../mocks/workflow.go -package mocks -self_package github.com/khulnasoft-lab/go-application-framework/pkg/workflow/
// typedefs
type Identifier = *url.URL
type Callback func(invocation InvocationContext, input []Data) ([]Data, error)
type ExtensionInit func(engine Engine) error
// interfaces
// Data is an interface that wraps the methods that are used to manage data that is passed between workflows.
type Data interface {
SetMetaData(key string, value string)
GetMetaData(key string) (string, error)
SetPayload(payload interface{})
GetPayload() interface{}
GetIdentifier() Identifier
GetContentType() string
GetContentLocation() string
SetContentLocation(string)
}
// InvocationContext is an interface that wraps various context information that is passed to a workflow when it is invoked.
type InvocationContext interface {
GetWorkflowIdentifier() Identifier
GetConfiguration() configuration.Configuration
GetEngine() Engine
GetAnalytics() analytics.Analytics
GetNetworkAccess() networking.NetworkAccess
GetLogger() *log.Logger
GetEnhancedLogger() *zerolog.Logger
GetUserInterface() ui.UserInterface
}
// ConfigurationOptions is an interface that can be implemented by any type that can be used to pass configuration options to a workflow.
type ConfigurationOptions interface {
}
// Entry is an interface that wraps the methods that are used to manage workflow entries.
type Entry interface {
GetEntryPoint() Callback
GetConfigurationOptions() ConfigurationOptions
IsVisible() bool
SetVisibility(visible bool)
}
// Engine is the interface that wraps the methods that are used to manage workflows.
type Engine interface {
Init() error
AddExtensionInitializer(initializer ExtensionInit)
Register(id Identifier, config ConfigurationOptions, callback Callback) (Entry, error)
GetWorkflows() []Identifier
GetWorkflow(id Identifier) (Entry, bool)
Invoke(id Identifier) ([]Data, error)
InvokeWithInput(id Identifier, input []Data) ([]Data, error)
InvokeWithConfig(id Identifier, config configuration.Configuration) ([]Data, error)
InvokeWithInputAndConfig(id Identifier, input []Data, config configuration.Configuration) ([]Data, error)
GetAnalytics() analytics.Analytics
GetNetworkAccess() networking.NetworkAccess
GetConfiguration() configuration.Configuration
SetLogger(logger *zerolog.Logger)
SetConfiguration(config configuration.Configuration)
GetLogger() *zerolog.Logger
GetUserInterface() ui.UserInterface
SetUserInterface(ui ui.UserInterface)
}