Documentation
¶
Index ¶
- func NewPlugin(logger hclog.Logger) drivers.DriverPlugin
- type Config
- type HelloDriverPlugin
- func (d *HelloDriverPlugin) Capabilities() (*drivers.Capabilities, error)
- func (d *HelloDriverPlugin) ConfigSchema() (*hclspec.Spec, error)
- func (d *HelloDriverPlugin) DestroyTask(taskID string, force bool) error
- func (d *HelloDriverPlugin) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)
- func (d *HelloDriverPlugin) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error)
- func (d *HelloDriverPlugin) InspectTask(taskID string) (*drivers.TaskStatus, error)
- func (d *HelloDriverPlugin) PluginInfo() (*base.PluginInfoResponse, error)
- func (d *HelloDriverPlugin) RecoverTask(handle *drivers.TaskHandle) error
- func (d *HelloDriverPlugin) SetConfig(cfg *base.Config) error
- func (d *HelloDriverPlugin) SignalTask(taskID string, signal string) error
- func (d *HelloDriverPlugin) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error)
- func (d *HelloDriverPlugin) StopTask(taskID string, timeout time.Duration, signal string) error
- func (d *HelloDriverPlugin) TaskConfigSchema() (*hclspec.Spec, error)
- func (d *HelloDriverPlugin) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error)
- func (d *HelloDriverPlugin) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error)
- func (d *HelloDriverPlugin) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error)
- type TaskConfig
- type TaskState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPlugin ¶
func NewPlugin(logger hclog.Logger) drivers.DriverPlugin
NewPlugin returns a new example driver plugin
Types ¶
type Config ¶
type Config struct { // TODO: create decoded plugin configuration struct // // This struct is the decoded version of the schema defined in the // configSpec variable above. It's used to convert the HCL configuration // passed by the Nomad agent into Go contructs. Shell string `codec:"shell"` }
Config contains configuration information for the plugin
type HelloDriverPlugin ¶
type HelloDriverPlugin struct {
// contains filtered or unexported fields
}
HelloDriverPlugin is an example driver plugin. When provisioned in a job, the taks will output a greet specified by the user.
func (*HelloDriverPlugin) Capabilities ¶
func (d *HelloDriverPlugin) Capabilities() (*drivers.Capabilities, error)
Capabilities returns the features supported by the driver.
func (*HelloDriverPlugin) ConfigSchema ¶
func (d *HelloDriverPlugin) ConfigSchema() (*hclspec.Spec, error)
ConfigSchema returns the plugin configuration schema.
func (*HelloDriverPlugin) DestroyTask ¶
func (d *HelloDriverPlugin) DestroyTask(taskID string, force bool) error
DestroyTask cleans up and removes a task that has terminated.
func (*HelloDriverPlugin) ExecTask ¶
func (d *HelloDriverPlugin) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)
ExecTask returns the result of executing the given command inside a task.
func (*HelloDriverPlugin) Fingerprint ¶
func (d *HelloDriverPlugin) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error)
Fingerprint returns a channel that will be used to send health information and other driver specific node attributes.
func (*HelloDriverPlugin) InspectTask ¶
func (d *HelloDriverPlugin) InspectTask(taskID string) (*drivers.TaskStatus, error)
InspectTask returns detailed status information for the referenced taskID.
func (*HelloDriverPlugin) PluginInfo ¶
func (d *HelloDriverPlugin) PluginInfo() (*base.PluginInfoResponse, error)
PluginInfo returns information describing the plugin.
func (*HelloDriverPlugin) RecoverTask ¶
func (d *HelloDriverPlugin) RecoverTask(handle *drivers.TaskHandle) error
RecoverTask recreates the in-memory state of a task from a TaskHandle.
func (*HelloDriverPlugin) SetConfig ¶
func (d *HelloDriverPlugin) SetConfig(cfg *base.Config) error
SetConfig is called by the client to pass the configuration for the plugin.
func (*HelloDriverPlugin) SignalTask ¶
func (d *HelloDriverPlugin) SignalTask(taskID string, signal string) error
SignalTask forwards a signal to a task.
func (*HelloDriverPlugin) StartTask ¶
func (d *HelloDriverPlugin) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error)
StartTask returns a task handle and a driver network if necessary.
func (*HelloDriverPlugin) StopTask ¶
StopTask stops a running task with the given signal and within the timeout window.
func (*HelloDriverPlugin) TaskConfigSchema ¶
func (d *HelloDriverPlugin) TaskConfigSchema() (*hclspec.Spec, error)
TaskConfigSchema returns the HCL schema for the configuration of a task.
func (*HelloDriverPlugin) TaskEvents ¶
TaskEvents returns a channel that the plugin can use to emit task related events.
func (*HelloDriverPlugin) TaskStats ¶
func (d *HelloDriverPlugin) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error)
TaskStats returns a channel which the driver should send stats to at the given interval.
func (*HelloDriverPlugin) WaitTask ¶
func (d *HelloDriverPlugin) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error)
WaitTask returns a channel used to notify Nomad when a task exits.
type TaskConfig ¶
type TaskConfig struct { // TODO: create decoded plugin task configuration struct // // This struct is the decoded version of the schema defined in the // taskConfigSpec variable above. It's used to convert the string // configuration for the task into Go contructs. Greeting string `codec:"greeting"` }
TaskConfig contains configuration information for a task that runs with this plugin
type TaskState ¶
type TaskState struct { ReattachConfig *structs.ReattachConfig TaskConfig *drivers.TaskConfig StartedAt time.Time // TODO: add any extra important values that must be persisted in order to // restore a task. // // The plugin keeps track of its running tasks in a in-memory data // structure. If the plugin crashes, this data will be lost, so Nomad will // respawn a new instance of the plugin and try to restore its in-memory // representation of the running tasks using the RecoverTask() method below. Pid int }
TaskState is the runtime state which is encoded in the handle returned to Nomad client. This information is needed to rebuild the task state and handler during recovery.