extio

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFormat = errors.New("unrecognized format")
	ErrLength = errors.New("invalid buffer length")
)

Functions

This section is empty.

Types

type Extio

type Extio struct {
	*core.StageBase

	Callback *pipe.Callback // our callback for capturing bgpipe output
	InputL   *pipe.Input    // our L input to bgpipe
	InputR   *pipe.Input    // our R input to bgpipe
	InputD   *pipe.Input    // default input if data doesn't specify the direction

	Output chan *bytebufferpool.ByteBuffer // output ready to be sent to the process
	Pool   *bytebufferpool.Pool            // pool of byte buffers
	// contains filtered or unexported fields
}

Extio helps in I/O with external processes eg. a background JSON filter, or a remote websocket processor. You must read Output and return disposed buffers using Put().

func NewExtio

func NewExtio(parent *core.StageBase, mode Mode) *Extio

NewExtio creates a new object for given stage.

func (*Extio) Attach

func (eio *Extio) Attach() error

Attach must be called from the parent stage attach

func (*Extio) InputClose

func (eio *Extio) InputClose() error

InputClose closes all stage inputs, stopping the flow from the process to bgpipe

func (*Extio) OutputClose

func (eio *Extio) OutputClose() error

OutputClose closes eio.Output, stopping the flow from bgpipe to the process

func (*Extio) Put

func (eio *Extio) Put(bb *bytebufferpool.ByteBuffer)

Put puts a byte buffer back to pool

func (*Extio) ReadBuf

func (eio *Extio) ReadBuf(buf []byte, cb pipe.CallbackFunc) (parse_err error)

ReadBuf reads all messages from the process, as bytes in buf, buffering if needed. Must not be used concurrently. cb may be nil.

func (*Extio) ReadSingle

func (eio *Extio) ReadSingle(buf []byte, cb pipe.CallbackFunc) (parse_err error)

ReadSingle reads single message from the process, as bytes in buf. Does not keep a reference to buf (copies buf if needed). Can be used concurrently. cb may be nil.

func (*Extio) ReadStream

func (eio *Extio) ReadStream(rd io.Reader, cb pipe.CallbackFunc) (parse_err error)

ReadStream is a ReadBuf wrapper that reads from an io.Reader. Must not be used concurrently. cb may be nil.

func (*Extio) SendMsg

func (eio *Extio) SendMsg(m *msg.Msg) bool

SendMsg queues BGP message to the process. Can be used concurrently.

func (*Extio) WriteStream

func (eio *Extio) WriteStream(w io.Writer) error

WriteStream rewrites eio.Output to w.

type Mode added in v0.8.8

type Mode = int
const (
	MODE_DEFAULT      = 0
	MODE_READ    Mode = 0x01 // no output from bgpipe
	MODE_WRITE   Mode = 0x02 // no input to bgpipe
	MODE_COPY    Mode = 0x10 // copy from pipe, don't drop
)

Jump to

Keyboard shortcuts

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