Documentation
¶
Index ¶
- func Executor(rq chan *CommandInput, wq chan *CommandOutput, cfgs []*CommandConfig)
- func ExecutorWithRunner(rq chan *CommandInput, wq chan *CommandOutput, cfgs []*CommandConfig, ...)
- type Cmd
- type CommandConfig
- type CommandInput
- type CommandOutput
- type CommandRunner
- type Definition
- type Matcher
- type OutputWriter
- type RunnerFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Executor ¶
func Executor(rq chan *CommandInput, wq chan *CommandOutput, cfgs []*CommandConfig)
func ExecutorWithRunner ¶ added in v0.2.0
func ExecutorWithRunner( rq chan *CommandInput, wq chan *CommandOutput, cfgs []*CommandConfig, runnerFactory RunnerFactory, )
ExecutorWithRunner runs commands using runners provided by runnerFactory.
Types ¶
type Cmd ¶ added in v0.2.0
type Cmd interface {
SetStdin(r io.Reader)
SetStdout(w io.Writer)
SetStderr(w io.Writer)
Run(timeout int) int
}
Cmd is an executable command abstraction for different runners.
type CommandConfig ¶
type CommandConfig struct {
*Definition
ReplyConfig interface{} //*pubsub.ReplyConfig
}
func NewCommandConfig ¶
func NewCommandConfig(def *Definition, replyConfig interface{}) *CommandConfig
type CommandInput ¶
type CommandInput struct {
ReplyInfo interface{} // PubSubの返信に必要な構造体(PubSubの種類ごとにキャストして利用する)
Text string // 起動コマンド平文
}
CommandInput はPubSubからの情報をExecutorに引き渡す構造体
type CommandOutput ¶
type CommandOutput struct {
ReplyInfo interface{}
ReplyConfig interface{}
Text string // コマンドからのテキスト出力(ImageData と排他)
ImageData []byte // sixel を変換した PNG バイト列(Text と排他)
IsErrOut bool
Spawned bool
Finished bool
ExitCode int
}
CommandOutput はExecutorからの実行結果を引き渡してPubSubに書き出すための構造体
type CommandRunner ¶ added in v0.2.0
type CommandRunner interface {
CommandContext(ctx context.Context, name string, arg ...string) Cmd
}
CommandRunner creates Cmd instances for a given command.
func NewComposeRunner ¶ added in v0.2.0
func NewComposeRunner(dir string, files ...string) CommandRunner
NewComposeRunner returns a runner backed by compose-exec. If dir is empty, it defaults to the current working directory.
func NewExecRunner ¶ added in v0.2.0
func NewExecRunner() CommandRunner
NewExecRunner returns a runner backed by os/exec.
func NewHTTPRunner ¶ added in v0.2.6
func NewHTTPRunner(cfg *CommandConfig) CommandRunner
NewHTTPRunner returns a runner backed by net/http.
type Definition ¶
type OutputWriter ¶
type OutputWriter struct {
// contains filtered or unexported fields
}
func (*OutputWriter) Flush ¶
func (w *OutputWriter) Flush() error
type RunnerFactory ¶ added in v0.2.0
type RunnerFactory func(cfg *CommandConfig) CommandRunner
RunnerFactory returns a runner for the given command config.
Click to show internal directories.
Click to hide internal directories.