Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var KnownCapabilities = []string{
"graceful-termination",
}
Functions ¶
This section is empty.
Types ¶
type Capabilities ¶
type Capabilities struct {
// contains filtered or unexported fields
}
func EmptyCapabilities ¶
func EmptyCapabilities() *Capabilities
func FromCapabilitiesList ¶
func FromCapabilitiesList(caplist []string) *Capabilities
func FullCapabilities ¶
func FullCapabilities() *Capabilities
func (*Capabilities) Add ¶
func (caps *Capabilities) Add(c string)
func (*Capabilities) Has ¶
func (caps *Capabilities) Has(c string) bool
func (*Capabilities) LimitTo ¶
func (caps *Capabilities) LimitTo(other *Capabilities)
func (*Capabilities) List ¶
func (caps *Capabilities) List() []string
func (*Capabilities) Remove ¶
func (caps *Capabilities) Remove(c string)
type FakeTransport ¶
type FakeTransport struct {
// contains filtered or unexported fields
}
FakeTransport implements Transport and records sent messages. It is used for testing.
func NewFakeTransport ¶
func NewFakeTransport() *FakeTransport
func (*FakeTransport) Messages ¶
func (transp *FakeTransport) Messages() []Message
func (*FakeTransport) Recv ¶
func (transp *FakeTransport) Recv() (Message, bool)
func (*FakeTransport) Send ¶
func (transp *FakeTransport) Send(msg Message)
type MessageCallback ¶
type MessageCallback func(msg Message)
type NullTransport ¶
type NullTransport struct{}
NullTransport implements Transport without doing anything. It's suitable for workers that do not implement the protocol
func NewNullTransport ¶
func NewNullTransport() *NullTransport
func (*NullTransport) Recv ¶
func (transp *NullTransport) Recv() (Message, bool)
func (*NullTransport) Send ¶
func (transp *NullTransport) Send(msg Message)
type Protocol ¶
type Protocol struct { // current set of agreed capabilities (but call WaitUntilInitialized first // to avoid finding the empty set at startup) Capabilities *Capabilities // contains filtered or unexported fields }
func NewProtocol ¶
func (*Protocol) Register ¶
func (prot *Protocol) Register(messageType string, callback MessageCallback)
Register a callback for the given message type. This must occur before the protocol is started.
func (*Protocol) Send ¶
Send a message. This happens without waiting for initialization; as the caller should already have used prot.Capable to determine whether the message was supported.
func (*Protocol) SetInitialized ¶
func (prot *Protocol) SetInitialized()
Set this protocol as initialized. Ordinarily this happens automatically, but in cases where the worker does not support the protocol, this method can be used to indicate that the protocol is "initialized" with no capabilities.
func (*Protocol) WaitUntilInitialized ¶
func (prot *Protocol) WaitUntilInitialized()
Wait until this protocol is initialized.
type StdioTransport ¶
type StdioTransport struct { // channels of incoming and outgoing messages In chan Message Out chan Message // a writer to which invalid lines are written, defaulting to // os.Stdout InvalidLines io.Writer // contains filtered or unexported fields }
StdioTransport implements the worker-runner protocol over stdin/stdout. It implements Transport, io.Reader and io.WriteCloser, where it uses the encoding defined in `protocol.md`, and exposes channels of incoming and outgoing messages.
func NewStdioTransport ¶
func NewStdioTransport() *StdioTransport
Create a new StdioTransport. The result implements both io.Reader and io.Writer so it can be specified as a cmd's Stdin and Stdout.
func (*StdioTransport) Close ¶
func (transp *StdioTransport) Close() error
func (*StdioTransport) Recv ¶
func (transp *StdioTransport) Recv() (Message, bool)
func (*StdioTransport) Send ¶
func (transp *StdioTransport) Send(msg Message)