Documentation ¶
Overview ¶
Package iobroker converts io.Read/Writers into opshell channels.
Index ¶
- Constants
- type Broker
- func (b *Broker) AddEventListener(ch chan<- Event)
- func (b *Broker) ConnectIn(ctx context.Context, sl *slog.Logger, addr string, w io.Writer, key string)
- func (b *Broker) ConnectInOut(ctx context.Context, sl *slog.Logger, addr string, w io.Writer, r io.Reader)
- func (b *Broker) ConnectOut(ctx context.Context, sl *slog.Logger, addr string, r io.Reader, key string)
- func (b *Broker) Do(ctx context.Context) error
- func (b *Broker) Errorf(addr, format string, a ...any)
- func (b *Broker) Logf(addr, format string, a ...any)
- func (b *Broker) RemoveEventListener(ch chan<- Event)
- type Event
- type EventType
Constants ¶
const ( // ShellReadyMessage is what we print when both sides of the shell are // connected. ShellReadyMessage = "Shell is ready to go!" // ShellDisconnectedMessage is what we print when both sides of the // shell are gone. ShellDisconnectedMessage = "Shell is gone :(" )
const ( LMAlreadyConnected = "Connection already established" LMDisconnected = "Disconnected" LMDisconnecting = "Previous shell disconnecting" LMIncorrectKey = "Incorrect key" LMKeyMissing = "Key missing" LMNewConnection = "New connection" LMShellIO = "Shell I/O" LMShuttingDown = "Shutting down" LKData = "data" LKDirection = "direction" LKError = "error" LKIncorrectKey = "incorrect_key" LKKey = "key" LVInput sDirection = "input" LVOutput sDirection = "output" )
Log messages, keys, and values.
const ( // EVChanLen is number of unsent events we'll buffer before blocking // happens. It may be used for other event channels' buffers as well. EVChanLen = 1024 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker handles I/O From shells. It ensures only one shell is connected at once, but also makes sure it disconnects properly.
func (*Broker) AddEventListener ¶
AddEventListener starts events being sent to ch. ch should be buffered.
func (*Broker) ConnectIn ¶
func (b *Broker) ConnectIn( ctx context.Context, sl *slog.Logger, addr string, w io.Writer, key string, )
ConnectIn connects w to a shell with the given key, which should match a corresponding call to ConnectOut. Addr is used for logging.
func (*Broker) ConnectInOut ¶
func (b *Broker) ConnectInOut( ctx context.Context, sl *slog.Logger, addr string, w io.Writer, r io.Reader, )
ConnectInOut connects a bidirectional connection to a shell. w and r may be the same io.ReadWriter.
func (*Broker) ConnectOut ¶
func (b *Broker) ConnectOut( ctx context.Context, sl *slog.Logger, addr string, r io.Reader, key string, )
ConnectOut connects r to a shell with the given key, which should match a corresponding call to ConnectOut.
func (*Broker) RemoveEventListener ¶
RemoveEventListener removes ch from the set of channels to which events will be sent. ch will not be closed, but no events will be sent to ch after RemoveEventListener returns.