Documentation ¶
Overview ¶
Package jobstream has helpers for working more easily with the GetJobStream endpoint, such as handling the full lifecycle of GetJobStream to a UI implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(s *stream) error
Option specifies an option for streaming.
func WithCancelOnError ¶
WithCancelOnError causes the job being watched to be canceled (with CancelJob) if the streamer exits unsuccessfully. Defaults to false.
func WithClient ¶
func WithClient(client pb.WaypointClient) Option
Set the client for the stream watcher. This is required.
func WithIgnoreTerminal ¶
WithIgnoreTerminal ignores the terminal events from the job. Other UI output may happen such as queue delays but the actual terminal events are hidden.
func WithStateCh ¶
WithStateCh sets a channel that is sent all the job state changes. This must not block. If the channel blocks, the entire stream watcher may be blocked.
type UI ¶
type UI struct { // The underlying UI that will be written to. UI terminal.UI // Log for unknown events and other diagnostics. Log hclog.Logger // contains filtered or unexported fields }
UI converts a stream of terminal events from a job stream into stateful function calls to a terminal.UI implementation.
func (*UI) Write ¶
func (s *UI) Write(events []*pb.GetJobStreamResponse_Terminal_Event) error
Write processes the given events and converts them to calls to UI. The order of the events matter because events are stateful: some events start a table, some end it, etc.
TODO(mitchellh): This was extracted directly from internal/client. It had no tests there and it still has no tests here. We should test this eventually and it should be pretty easy to do so!