/
runner.go
64 lines (47 loc) · 1.34 KB
/
runner.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
package base
import (
"context"
"io"
"github.com/codefly-dev/core/configurations"
)
/*
A RunnerEnvironment controls running processes.
Implementations:
- local
- docker
- kubernetes (future)
*/
type RunnerEnvironment interface {
// Init setup the environment
Init(ctx context.Context) error
// Clear removes all resources
Clear(ctx context.Context) error
// NewProcess creates a new process for the environment
NewProcess(bin string, args ...string) (Proc, error)
// Stop the environment: can potentially be restarted
Stop(ctx context.Context) error
// Shutdown the environment: all resources will be deleted
Shutdown(ctx context.Context) error
// WithEnvironmentVariables sets the environment variables
WithEnvironmentVariables(envs ...configurations.EnvironmentVariable)
}
type Proc interface {
Start(ctx context.Context) error
Run(ctx context.Context) error
Stop(ctx context.Context) error
WithOutput(w io.Writer)
WithEnvironmentVariables(envs ...configurations.EnvironmentVariable)
}
type Runner interface {
// Setting parameters
WithDir(dir string)
WithEnvironmentVariables(envs ...configurations.EnvironmentVariable)
WithBin(bin string)
WithArguments(args ...string)
WithOutput(w io.Writer)
// Interface
Init(ctx context.Context) error
Run(ctx context.Context) error
Start(ctx context.Context) error
Stop() error
}