Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChanSource ¶
type ChanSource struct {
// contains filtered or unexported fields
}
ChanSource is a bidirectional channel source that supports both reading and writing. It implements InputSource and provides a Write method for injecting messages.
func NewChanSource ¶
func NewChanSource(buffer int) *ChanSource
NewChanSource creates a new ChanSource with the given buffer size.
func (*ChanSource) C ¶
func (s *ChanSource) C() chan<- any
C returns the underlying channel for external use.
func (*ChanSource) Read ¶
func (s *ChanSource) Read(ctx context.Context) (any, error)
Read implements InputSource. It blocks until a message is available or context is done.
func (*ChanSource) Write ¶
func (s *ChanSource) Write(msg any)
Write injects a message into the source. It's non-blocking - if the channel is full, the message is dropped.
type ChannelSource ¶
type ChannelSource struct {
// contains filtered or unexported fields
}
ChannelSource reads messages from a channel
func NewChannelSource ¶
func NewChannelSource(ch <-chan any) *ChannelSource
type InputSource ¶
InputSource defines where input messages come from
type OutputHandler ¶
type OutputHandler func(ctx context.Context, c *IOContext) (*OutputResult, error)
type OutputResult ¶
当 Output 触发额外输入时返回这个
type Runner ¶
type Runner struct {
// Codec mode for input/output
Codec CodecMode
InputSource InputSource
InputHandler InputHandler
OutputHandler OutputHandler
// contains filtered or unexported fields
}
func New ¶
func New( cmd *exec.Cmd, inputHandler InputHandler, outputHandler OutputHandler, ) *Runner
type StdinSource ¶
type StdinSource struct {
// contains filtered or unexported fields
}
StdinSource reads JSON messages from os.Stdin
func NewStdinSource ¶
func NewStdinSource() *StdinSource