ipc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package ipc contains the public cross-process inference contract. Worker supervision and wire framing remain internal; applications depend only on this context-aware interface and can supply in-process, subprocess, or remote implementations without coupling models to a transport.

Index

Constants

This section is empty.

Variables

View Source
var ErrInferenceExecutorClosed = errors.New("ipc: inference executor is closed")

Functions

func IsInferenceExecutor

func IsInferenceExecutor(value any) bool

IsInferenceExecutor reports whether value is a non-nil executor without invoking it. It safely handles typed nil interfaces.

Types

type Dispatcher

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

Dispatcher provides a deterministic, allocation-light method registry for local and subprocess executors. Registration is intended for startup; Seal turns the registry immutable and enables lock-free dispatch reads.

func NewDispatcher

func NewDispatcher() *Dispatcher

func (*Dispatcher) DoInference

func (d *Dispatcher) DoInference(ctx context.Context, method string, data any) (any, error)

func (*Dispatcher) Register

func (d *Dispatcher) Register(method string, handler InferenceExecutorFunc) error

func (*Dispatcher) Seal

func (d *Dispatcher) Seal()

type InferenceExecutor

type InferenceExecutor interface {
	DoInference(context.Context, string, any) (any, error)
}

InferenceExecutor is the Go equivalent of agents-js doInference(method, data). Context cancellation is mandatory in Go so a dead child process or native model can never pin job shutdown indefinitely.

type InferenceExecutorFunc

type InferenceExecutorFunc func(context.Context, string, any) (any, error)

InferenceExecutorFunc adapts a function to InferenceExecutor.

func (InferenceExecutorFunc) DoInference

func (f InferenceExecutorFunc) DoInference(ctx context.Context, method string, data any) (any, error)

type Request

type Request struct {
	ID     string `json:"id,omitempty"`
	Method string `json:"method"`
	Data   any    `json:"data,omitempty"`
}

Request is a transport-neutral inference request. ID is optional for direct executors and required by multiplexed transports.

type Response

type Response struct {
	ID   string `json:"id,omitempty"`
	Data any    `json:"data,omitempty"`
	Err  error  `json:"-"`
}

Response carries either Data or Err. Transport implementations should map remote error codes to a typed error before returning from DoInference.

type UnknownMethodError

type UnknownMethodError struct{ Method string }

func (*UnknownMethodError) Error

func (e *UnknownMethodError) Error() string

Jump to

Keyboard shortcuts

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