-
Notifications
You must be signed in to change notification settings - Fork 2
/
interface.go
57 lines (50 loc) · 2.21 KB
/
interface.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
// Package deployer provides interfaces for all deployers of plugins to follow.
package deployer
import (
"context"
"io"
log "go.arcalot.io/log/v2"
"go.flow.arcalot.io/pluginsdk/schema"
)
// DeploymentType is the mechanism of deployment, such as
// image or python.
type DeploymentType string
// ConnectorFactory is an abstraction that hides away the complexity of instantiating a Connector. Its main purpose is
// to provide the configuration schema for the connector and then create an instance of said connector.
type ConnectorFactory[ConfigType any] interface {
Name() string
ConfigurationSchema() *schema.TypedScopeSchema[ConfigType]
Create(config ConfigType, logger log.Logger) (Connector, error)
DeploymentType() DeploymentType
}
// AnyConnectorFactory is the untyped version of ConnectorFactory.
type AnyConnectorFactory interface {
Name() string
ConfigurationSchema() schema.Object
Create(config any, logger log.Logger) (Connector, error)
DeploymentType() DeploymentType
}
// Connector is responsible for deploying a container image on the specified target. Once deployed and ready, the
// connector returns an I/O to communicate with the plugin.
type Connector interface {
// Deploy instructs the connector to aquire the plugin and run it,
// resulting in the plugin starting its ATP server.
// The ATP server will be accessible through the `Plugin` interface.
//
// Parameters:
// ctx: The context that lasts the length of the deployment.
// A cancelled context means the plugin is in the process of getting shut down, or is shut down. No new
// deployment should be allowed.
// pluginSource: The source of the plugin. This can be the tag of the image to run, a Python module, or
// anything else that the deployer supports.
Deploy(ctx context.Context, pluginSource string) (Plugin, error)
}
// Plugin is single, possibly containerized instance of a plugin. When read from, this interface provides the stdout of
// the plugin, supposedly talking the Arcaflow Transport Protocol, whereas the writer will write to the standard input
// of the plugin. The Close() method will shut the plugin down and return when the shutdown was successful.
type Plugin interface {
io.Reader
io.Writer
io.Closer
ID() string
}