Documentation ¶
Index ¶
- Constants
- func New(ctx context.Context) context.Context
- type Context
- func (ctx *Context) Get(host string) (e Executor)
- func (ctx *Context) GetCheckResults(host string) (results []interface{}, ok bool)
- func (ctx *Context) GetExecutor(host string) (e Executor, ok bool)
- func (ctx *Context) GetOutputs(hostID string) ([]byte, []byte, bool)
- func (ctx *Context) GetSSHKeySet() (privateKeyPath, publicKeyPath string)
- func (ctx *Context) SetCheckResults(host string, results []interface{})
- func (ctx *Context) SetExecutor(host string, e Executor)
- func (ctx *Context) SetOutputs(hostID string, stdout []byte, stderr []byte)
- type EventBus
- func (ev *EventBus) PublishTaskBegin(task fmt.Stringer)
- func (ev *EventBus) PublishTaskFinish(task fmt.Stringer, err error)
- func (ev *EventBus) PublishTaskProgress(task fmt.Stringer, progress string)
- func (ev *EventBus) Subscribe(eventName EventKind, handler interface{})
- func (ev *EventBus) Unsubscribe(eventName EventKind, handler interface{})
- type EventKind
- type Executor
- type ExecutorGetter
Constants ¶
const (
// CtxBaseTopo is key of store the base topology in context.Context
CtxBaseTopo = contextKey("BASE_TOPO")
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct { Ev EventBus // The private/public key is used to access remote server via the user `tidb` PrivateKeyPath string PublicKeyPath string // contains filtered or unexported fields }
Context is used to share state while multiple tasks execution. We should use mutex to prevent concurrent R/W for some fields because of the same context can be shared in parallel tasks.
func (*Context) GetCheckResults ¶
GetCheckResults get the the check result of a host (if has any)
func (*Context) GetExecutor ¶
GetExecutor get the executor.
func (*Context) GetOutputs ¶
GetOutputs get the outputs of a host (if has any)
func (*Context) GetSSHKeySet ¶
GetSSHKeySet implements the operation.ExecutorGetter interface.
func (*Context) SetCheckResults ¶
SetCheckResults append the check result of a host to the list
func (*Context) SetExecutor ¶
SetExecutor set the executor.
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus is an event bus for task events.
func (*EventBus) PublishTaskBegin ¶
PublishTaskBegin publishes a TaskBegin event. This should be called only by Parallel or Serial.
func (*EventBus) PublishTaskFinish ¶
PublishTaskFinish publishes a TaskFinish event. This should be called only by Parallel or Serial.
func (*EventBus) PublishTaskProgress ¶
PublishTaskProgress publishes a TaskProgress event.
func (*EventBus) Unsubscribe ¶
Unsubscribe unsubscribes events.
type EventKind ¶
type EventKind string
EventKind is the task event kind.
const ( // EventTaskBegin is emitted when a task is going to be executed. EventTaskBegin EventKind = "task_begin" // EventTaskFinish is emitted when a task finishes executing. EventTaskFinish EventKind = "task_finish" // EventTaskProgress is emitted when a task has made some progress. EventTaskProgress EventKind = "task_progress" )
type Executor ¶
type Executor interface { // Execute run the command, then return it's stdout and stderr // NOTE: stdin is not supported as it seems we don't need it (for now). If // at some point in the future we need to pass stdin to a command, we'll // need to refactor this function and its implementations. // If the cmd can't quit in timeout, it will return error, the default timeout is 60 seconds. Execute(ctx context.Context, cmd string, sudo bool, timeout ...time.Duration) (stdout []byte, stderr []byte, err error) // Transfer copies files from or to a target Transfer(ctx context.Context, src, dst string, download bool, limit int) error }
Executor is the executor interface for TiUP, all tasks will in the end be passed to a executor and then be actually performed.
type ExecutorGetter ¶
type ExecutorGetter interface { Get(host string) (e Executor) // GetSSHKeySet gets the SSH private and public key path GetSSHKeySet() (privateKeyPath, publicKeyPath string) }
ExecutorGetter get the executor by host.