stdioipc

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Receive

func Receive[T any, MT ~string](c *IO[MT], recvType MT) chan ReceivedEvent[MT, T]

Types

type IO

type IO[MT ~string] struct {
	// contains filtered or unexported fields
}

func NewIO

func NewIO[MT ~string](ctx context.Context, cancel context.CancelFunc, read io.ReadCloser, write io.Writer) *IO[MT]

func (*IO[MT]) Done

func (c *IO[MT]) Done() <-chan struct{}

func (*IO[MT]) NewThread

func (c *IO[MT]) NewThread() *Thread[MT]

func (*IO[MT]) Send

func (c *IO[MT]) Send(typ MT, payload any) bool

func (*IO[MT]) SendId

func (c *IO[MT]) SendId(id string, typ MT, payload any) bool

type Message

type Message[MT ~string] struct {
	Id      string          `json:"id"`
	Type    MT              `json:"type"`
	Payload json.RawMessage `json:"payload"`
}

func SendAndReceive

func SendAndReceive[T any, MT ~string](t *Thread[MT], sendType MT, sendPayload any, recvType MT) (T, Message[MT])

type ReceivedEvent

type ReceivedEvent[MT ~string, T any] struct {
	Payload T
	Message Message[MT]
	Thread  *Thread[MT]
	Error   bool
}

func ReceiveOnce

func ReceiveOnce[T any, MT ~string](c *IO[MT], timeout time.Duration, recvType MT) ReceivedEvent[MT, T]

type Thread

type Thread[MT ~string] struct {
	// contains filtered or unexported fields
}

Thread is intentionally not goroutine-safe and is expected to have a single owner.

func NewThread

func NewThread[MT ~string](id string, io *IO[MT]) *Thread[MT]

func (*Thread[MT]) ID

func (t *Thread[MT]) ID() string

func (*Thread[MT]) Send

func (t *Thread[MT]) Send(typ MT, payload any) bool

type Transport

type Transport[MT ~string] struct {
	// contains filtered or unexported fields
}

func NewTransport

func NewTransport[MT ~string](ctx context.Context, cancel context.CancelFunc, in io.ReadCloser, out io.Writer) *Transport[MT]

func (*Transport[MT]) Done

func (t *Transport[MT]) Done() <-chan struct{}

func (*Transport[MT]) Read

func (t *Transport[MT]) Read() <-chan Message[MT]

func (*Transport[MT]) Send

func (t *Transport[MT]) Send(msg Message[MT]) bool

Jump to

Keyboard shortcuts

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