Documentation ¶
Index ¶
- func EmptyCapabilities() *capabilities
- func FromCapabilitiesList(caplist []string) *capabilities
- type Message
- type MessageCallback
- type NullTransport
- type PipeTransport
- type Protocol
- func (prot *Protocol) AddCapability(c string)
- func (prot *Protocol) Capable(c string) bool
- func (prot *Protocol) Register(messageType string, callback MessageCallback)
- func (prot *Protocol) Send(msg Message)
- func (prot *Protocol) SetInitialized()
- func (prot *Protocol) Start(asWorker bool)
- func (prot *Protocol) WaitForEOF()
- func (prot *Protocol) WaitUntilInitialized()
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmptyCapabilities ¶
func EmptyCapabilities() *capabilities
func FromCapabilitiesList ¶
func FromCapabilitiesList(caplist []string) *capabilities
Types ¶
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 PipeTransport ¶
type PipeTransport struct {
// contains filtered or unexported fields
}
PipeTransport implements the worker-runner protocol over a pipe. It reads from its input in the `Recv` method, and writes to its output in Send. It is safe to assume that a message has been handed to the OS when Send returns.
func NewPipeTransport ¶
func NewPipeTransport(input io.Reader, output io.Writer) *PipeTransport
Create a new PipeTransport. The result will read from input and write to output.
func (*PipeTransport) Recv ¶
func (transp *PipeTransport) Recv() (msg Message, ok bool)
func (*PipeTransport) Send ¶
func (transp *PipeTransport) Send(msg Message)
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
func NewProtocol ¶
func (*Protocol) AddCapability ¶
Add the given capability to the local capabilities
func (*Protocol) Capable ¶
Check if a capability is supported by both ends of the protocol, after waiting for initialization.
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) WaitForEOF ¶
func (prot *Protocol) WaitForEOF()
Wait until all message have been read from the transport.
func (*Protocol) WaitUntilInitialized ¶
func (prot *Protocol) WaitUntilInitialized()
Wait until this protocol is initialized.