Documentation ¶
Overview ¶
Package cluster implements a client for the Owo host service.
Index ¶
- Variables
- func ExtractHostID(id string) (string, error)
- func ExtractUUID(id string) (string, error)
- func GenerateJobID(hostID, uuid string) string
- func HostTagsFromMeta(meta map[string]string) map[string]string
- func WaitForHostStatus(hostIP string, desired func(*host.HostStatus) bool) (*host.HostStatus, error)
- type AttachClient
- type Client
- type Host
- func (c *Host) AddJob(job *host.Job) error
- func (c *Host) AddSink(info *ct.Sink) error
- func (c *Host) Addr() string
- func (c *Host) Attach(req *host.AttachReq, wait bool) (AttachClient, error)
- func (c *Host) CreateSnapshot(volumeID string) (*volume.Info, error)
- func (c *Host) CreateVolume(providerId string, info *volume.Info) error
- func (c *Host) DestroyVolume(volumeID string) error
- func (c *Host) DiscoverdDeregisterJob(id string) error
- func (c *Host) GetJob(id string) (*host.ActiveJob, error)
- func (c *Host) GetSinks() ([]*ct.Sink, error)
- func (c *Host) GetStatus() (*host.HostStatus, error)
- func (c *Host) GetVolume(volumeID string) (*volume.Info, error)
- func (c *Host) ID() string
- func (c *Host) ListActiveJobs() (map[string]host.ActiveJob, error)
- func (c *Host) ListJobs() (map[string]host.ActiveJob, error)
- func (c *Host) ListVolumes() ([]*volume.Info, error)
- func (c *Host) PullBinariesAndConfig(repository, binDir, configDir, version string, tufDB io.Reader) (map[string]string, error)
- func (c *Host) PullImages(repository, configDir, version string, tufDB io.Reader, ...) (stream.Stream, error)
- func (c *Host) PullSnapshot(receiveVolID string, sourceHostID string, sourceSnapID string) (*volume.Info, error)
- func (c *Host) RemoveSink(id string) error
- func (c *Host) ResourceCheck(request host.ResourceCheck) error
- func (c *Host) SendSnapshot(snapID string, assumeHaves []json.RawMessage) (io.ReadCloser, error)
- func (c *Host) SignalJob(id string, sig int) error
- func (c *Host) StopJob(id string) error
- func (c *Host) StreamEvents(id string, ch chan *host.Event) (stream.Stream, error)
- func (c *Host) StreamVolumes(ch chan *volume.Event) (stream.Stream, error)
- func (c *Host) Tags() map[string]string
- func (c *Host) Update(name string, args ...string) (pid int, err error)
- func (c *Host) UpdateTags(tags map[string]string) error
- func (c *Host) UpdateWithShutdownDelay(name string, delay time.Duration, args ...string) (pid int, err error)
- type ServiceFunc
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("cluster: resource not found")
ErrNotFound is returned when a resource is not found (HTTP status 404).
var ErrWouldWait = errors.New("cluster: attach would wait")
ErrWouldWait is returned when the Attach should not wait, but the job is not running.
Functions ¶
func ExtractHostID ¶
ExtractHostID returns the host ID component of a job ID, returning an error if the given ID is invalid.
func ExtractUUID ¶
ExtractUUID returns the UUID component of a job ID, returning an error if the given ID is invalid.
func GenerateJobID ¶
GenerateJobID returns a random job identifier, prefixed with the given host ID.
func WaitForHostStatus ¶
Types ¶
type AttachClient ¶
type AttachClient interface { // Conn returns the underlying transport stream for the client. Conn() io.ReadWriteCloser // Receive reads stdout/stderr frames from the connection and writes them to // stdout and stderr. If the job exits, the return int will be set to the // exit code. Receive(stdout, stderr io.Writer) (int, error) // Wait waits for the job to start. It may optionally be called before // calling Receive. Wait() error // Signal sends a Unix signal to the job. Signal(int) error // ResizeTTY resizes the job's TTY. ResizeTTY(height, width uint16) error // CloseWrite sends an EOF to the stdin stream. CloseWrite() error // Writer allows writing to the stdin stream. io.Writer // Closer allows closing the underlying transport connection. io.Closer }
An AttachClient provides access to the stdin/stdout/stderr streams of a job and allows sending UNIX signals to it.
func NewAttachClient ¶
func NewAttachClient(conn io.ReadWriteCloser) AttachClient
NewAttachClient wraps conn in an implementation of AttachClient.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is used to discover members of the owo-host cluster.
func NewClient ¶
func NewClient() *Client
NewClient uses the default discoverd configuration to create a cluster client.
func NewClientWithHTTP ¶
func NewClientWithHTTP(services ServiceFunc, hc *http.Client) *Client
func NewClientWithServices ¶
func NewClientWithServices(services ServiceFunc) *Client
NewClientWithServices uses the provided services to find cluster members. If services is nil, the default discoverd client is used.
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host is a client for a host daemon.
func NewHost ¶
NewHost creates a new Host that uses client to communicate with it. addr is used by Attach.
func (*Host) Attach ¶
func (c *Host) Attach(req *host.AttachReq, wait bool) (AttachClient, error)
Attach attaches to the job specified in req and returns an attach client. If wait is true, the client will wait for the job to start before returning the first bytes. If wait is false and the job is not running, ErrWouldWait is returned.
func (*Host) CreateSnapshot ¶
Create snapshot creates a snapshot of a volume on a host.
func (*Host) CreateVolume ¶
CreateVolume a new volume with the given configuration. When in doubt, use a providerId of "default".
func (*Host) DestroyVolume ¶
DestroyVolume deletes a volume by ID
func (*Host) DiscoverdDeregisterJob ¶
DiscoverdDeregisterJob requests a job to deregister from service discovery.
func (*Host) ListActiveJobs ¶
ListActiveJobs lists starting or running jobs on the host.
func (*Host) ListVolumes ¶
ListVolume returns a list of volume IDs
func (*Host) PullBinariesAndConfig ¶
func (c *Host) PullBinariesAndConfig(repository, binDir, configDir, version string, tufDB io.Reader) (map[string]string, error)
PullBinariesAndConfig pulls binaries and config from a TUF repository using the local TUF file in tufDB
func (*Host) PullImages ¶
func (c *Host) PullImages(repository, configDir, version string, tufDB io.Reader, ch chan *ct.ImagePullInfo) (stream.Stream, error)
PullImages pulls images from a TUF repository using the local TUF file in tufDB
func (*Host) PullSnapshot ¶
func (c *Host) PullSnapshot(receiveVolID string, sourceHostID string, sourceSnapID string) (*volume.Info, error)
PullSnapshot requests the host pull a snapshot from another host onto one of its volumes. Returns the info for the new snapshot.
func (*Host) RemoveSink ¶
func (*Host) ResourceCheck ¶
func (*Host) SendSnapshot ¶
func (c *Host) SendSnapshot(snapID string, assumeHaves []json.RawMessage) (io.ReadCloser, error)
SendSnapshot requests transfer of volume snapshot data (this is used by other hosts in service of the PullSnapshot request).
func (*Host) StreamEvents ¶
StreamEvents about job state changes to ch. id may be "all" or a single job ID.
func (*Host) StreamVolumes ¶
StreamVolumes streams volume events to the given channel
type ServiceFunc ¶
type ServiceFunc func(name string) discoverd.Service
A ServiceFunc is a function that takes a service name and returns a discoverd.Service.