Documentation
¶
Index ¶
- Constants
- type Intermediate
- type Mock
- func (svc *Mock) Execute(ctx context.Context, cmd string, workDir string, stdin string, ...) (exitCode int, stdout string, stderr string, err error)
- func (svc *Mock) MockExecute(...) *Mock
- func (svc *Mock) OnShutdown(ctx context.Context) (err error)
- func (svc *Mock) OnStartup(ctx context.Context) (err error)
- type Service
- func (svc *Service) Execute(ctx context.Context, cmd string, workDir string, stdin string, ...) (exitCode int, stdout string, stderr string, err error)
- func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service
- func (svc *Service) OnShutdown(ctx context.Context) (err error)
- func (svc *Service) OnStartup(ctx context.Context) (err error)
- type ToDo
Constants ¶
const ( Hostname = shellapi.Hostname Version = 4 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Intermediate ¶
Intermediate extends and customizes the generic base connector.
func NewIntermediate ¶
func NewIntermediate(impl ToDo) *Intermediate
NewIntermediate creates a new instance of the intermediate.
func (*Intermediate) MaxOutputBytes ¶
func (svc *Intermediate) MaxOutputBytes() (value int)
MaxOutputBytes caps the number of bytes retained from each of stdout and stderr. When a stream exceeds this cap, the head and tail are kept and the middle is elided with a marker. The command is not killed; excess output is silently discarded so the child can run to completion.
func (*Intermediate) SetMaxOutputBytes ¶
func (svc *Intermediate) SetMaxOutputBytes(value int) (err error)
SetMaxOutputBytes sets the value of the configuration property.
type Mock ¶
type Mock struct {
*Intermediate
// contains filtered or unexported fields
}
Mock is a mockable version of the microservice, allowing functions, event sinks and web handlers to be mocked.
func (*Mock) Execute ¶
func (svc *Mock) Execute(ctx context.Context, cmd string, workDir string, stdin string, envars map[string]string) (exitCode int, stdout string, stderr string, err error)
Execute executes the mock handler.
func (*Mock) MockExecute ¶
func (svc *Mock) MockExecute(handler func(ctx context.Context, cmd string, workDir string, stdin string, envars map[string]string) (exitCode int, stdout string, stderr string, err error)) *Mock
MockExecute sets up a mock handler for Execute.
func (*Mock) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
type Service ¶
type Service struct {
*Intermediate // IMPORTANT: Do not remove
}
Service implements the shell.core microservice.
Shell enables running shell commands on a host machine. It executes commands in a subprocess and returns the exit code, standard output, and standard error.
func (*Service) Execute ¶
func (svc *Service) Execute(ctx context.Context, cmd string, workDir string, stdin string, envars map[string]string) (exitCode int, stdout string, stderr string, err error)
Execute runs a shell command on the host and returns the exit code, standard output, and standard error.
Input:
- cmd: the shell command to execute
- workDir: optional working directory for the command
- stdin: optional standard input to feed to the command
- envars: optional environment variables to set for the command, as key-value pairs
Output:
- exitCode: the exit code of the command
- stdout: the standard output of the command
- stderr: the standard error of the command
func (*Service) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
type ToDo ¶
type ToDo interface {
OnStartup(ctx context.Context) (err error)
OnShutdown(ctx context.Context) (err error)
Execute(ctx context.Context, cmd string, workDir string, stdin string, envars map[string]string) (exitCode int, stdout string, stderr string, err error) // MARKER: Execute
}
ToDo is implemented by the service or mock. The intermediate delegates handling to this interface.