Documentation ¶
Overview ¶
This package contains an implementation of worker-runner's worker protocol.
It is used to communicate with worker-runner in order to signal shutdown, log and refresh credentials, for example.
Index ¶
- func AddGracefulTermination(c *Communicator) <-chan bool
- func AddLogger(c *Communicator, parent logr.Logger) logr.Logger
- func AddRemoteShutdown(c *Communicator) func() error
- func Parse(log logr.Logger, r io.Reader, f ProtoHandler) error
- func Write(w io.Writer, packet interface{}) error
- type Communicator
- type MessageHandler
- type ProtoHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddGracefulTermination ¶
func AddGracefulTermination(c *Communicator) <-chan bool
AddGracefulTermination adds worker support for being asked to exit gracefully.
func AddLogger ¶
func AddLogger(c *Communicator, parent logr.Logger) logr.Logger
AddLogger adds logger support to the communicator.
This must be called before Run() is called on the communicator.
func AddRemoteShutdown ¶
func AddRemoteShutdown(c *Communicator) func() error
AddRemoteShutdown adds worker support for being remotely shutdown by the runner.
Types ¶
type Communicator ¶
type Communicator struct {
// contains filtered or unexported fields
}
Communicator runs a duplex stream to the worker-runner.
func NewCommunicator ¶
func NewCommunicator(log logr.Logger, isWorker bool) *Communicator
NewCommunicator creates a new communicator given the log and whather the communicator should act as the worker or runner.
Run must be called with the input and output streams to manage the communicator.
func (*Communicator) AddCapability ¶
func (c *Communicator) AddCapability(cap string)
AddCapability marks this communicator as supporting a given capability.
It must not be called after Run() has been called.
func (*Communicator) AddHandler ¶
func (c *Communicator) AddHandler(packetType string, handler MessageHandler)
AddHandler adds a handler for a given packet type.
It must not be called after Run() has been called.
func (*Communicator) HasCapability ¶
func (c *Communicator) HasCapability(cap string) bool
HasCapability returns true if both ends support a capability.
func (*Communicator) Send ¶
func (c *Communicator) Send(packet interface{}) error
Send a packet over the communicator.
type MessageHandler ¶
MessageHandler is used to implement a single workerproto packet.
type ProtoHandler ¶
ProtoHandler is used by the low-level transport code to handle messages from an input stream.