stdio

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package stdio provides a Transport implementation that uses standard input/output.

Package stdio provides a Transport implementation that uses standard input/output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StdioTransport

type StdioTransport struct {
	// contains filtered or unexported fields
}

StdioTransport implements the Transport interface using standard input/output. It reads messages from stdin using a dedicated reader goroutine and writes messages to stdout.

func NewStdioTransport

func NewStdioTransport() *StdioTransport

NewStdioTransport creates a new StdioTransport with default options.

func NewStdioTransportWithOptions

func NewStdioTransportWithOptions(opts types.TransportOptions) *StdioTransport

NewStdioTransportWithOptions creates a new StdioTransport with the specified options.

func NewStdioTransportWithReadWriter

func NewStdioTransportWithReadWriter(reader io.Reader, writer io.Writer, opts types.TransportOptions) *StdioTransport

NewStdioTransportWithReadWriter creates a new StdioTransport using the provided reader/writer.

func (*StdioTransport) Close

func (t *StdioTransport) Close() error

Close signals the reader goroutine to stop and attempts to close the underlying reader/writer.

func (*StdioTransport) EstablishReceiver added in v0.1.11

func (t *StdioTransport) EstablishReceiver(ctx context.Context) error

EstablishReceiver for StdioTransport does nothing, as the reader is started automatically during construction. It exists to satisfy the Transport interface.

func (*StdioTransport) IsClosed added in v0.1.11

func (t *StdioTransport) IsClosed() bool

IsClosed returns true if the transport has been closed.

func (*StdioTransport) Receive

func (t *StdioTransport) Receive(ctx context.Context) ([]byte, error)

Receive reads the next available message from the internal channel, waiting if necessary. It respects the provided context for cancellation. This replaces the old Receive and ReceiveWithContext methods.

func (*StdioTransport) Send

func (t *StdioTransport) Send(ctx context.Context, data []byte) error

Send writes a message to the underlying writer (stdout), respecting the context. It ensures the message ends with a newline and handles locking and flushing.

type StdioTransportFactory

type StdioTransportFactory struct {
	// contains filtered or unexported fields
}

StdioTransportFactory creates StdioTransport instances.

func NewStdioTransportFactory

func NewStdioTransportFactory() *StdioTransportFactory

NewStdioTransportFactory creates a new StdioTransportFactory with default options.

func NewStdioTransportFactoryWithOptions

func NewStdioTransportFactoryWithOptions(opts types.TransportOptions) *StdioTransportFactory

NewStdioTransportFactoryWithOptions creates a new StdioTransportFactory with the specified default options.

func (*StdioTransportFactory) NewTransport

func (f *StdioTransportFactory) NewTransport() (types.Transport, error)

NewTransport creates a new StdioTransport with the factory's default options.

func (*StdioTransportFactory) NewTransportWithOptions

func (f *StdioTransportFactory) NewTransportWithOptions(opts types.TransportOptions) (types.Transport, error)

NewTransportWithOptions creates a new StdioTransport with the specified options, potentially overriding the factory's defaults (though current implementation just uses provided opts).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL