Documentation ¶
Overview ¶
Copyright © 2020 Marvin
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- func New(ctx context.Context, limit int, logger *printer.Logger) context.Context
- type Context
- func (ctx *Context) Get(host string) (e executor.Executor)
- func (ctx *Context) GetCheckResults(host string) (results []any, ok bool)
- func (ctx *Context) GetExecutor(host string) (e executor.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 []any)
- func (ctx *Context) SetExecutor(host string, e executor.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 any)
- func (ev *EventBus) Unsubscribe(eventName EventKind, handler any)
- type EventKind
- type ExecutorGetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct { Mutex sync.RWMutex Ev EventBus Exec struct { Executors map[string]executor.Executor Stdouts map[string][]byte Stderrs map[string][]byte CheckResults map[string][]interface{} } // Private key/public key is used to access the remote server through the user PrivateKeyPath string PublicKeyPath string Concurrency int // max number of parallel tasks running at the same time }
Context is used to share state when multiple tasks are executed. Use Mutex locks to prevent concurrent reading/writing of certain fields Because 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" )