rpc

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeParse          = -32700
	ErrCodeInvalidRequest = -32600
	ErrCodeMethodNotFound = -32601
	ErrCodeInvalidParams  = -32602
	ErrCodeInternal       = -32603
	ErrCodeVMFailed       = -32000
	ErrCodeExecFailed     = -32001
	ErrCodeFileFailed     = -32002
	ErrCodeCancelled      = -32003
)

Variables

This section is empty.

Functions

func RunRPC

func RunRPC(ctx context.Context, factory VMFactory) error

Types

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type Handler

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

func NewHandler

func NewHandler(factory VMFactory, stdin io.Reader, stdout io.Writer) *Handler

func (*Handler) Run

func (h *Handler) Run(ctx context.Context) error

type Request

type Request struct {
	JSONRPC string          `json:"jsonrpc"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
	ID      *uint64         `json:"id,omitempty"`
}

type Response

type Response struct {
	JSONRPC string      `json:"jsonrpc"`
	Result  interface{} `json:"result,omitempty"`
	Error   *Error      `json:"error,omitempty"`
	ID      *uint64     `json:"id,omitempty"`
}

type VM

type VM interface {
	ID() string
	Config() *api.Config
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
	Exec(ctx context.Context, command string, opts *api.ExecOptions) (*api.ExecResult, error)
	WriteFile(ctx context.Context, path string, content []byte, mode uint32) error
	ReadFile(ctx context.Context, path string) ([]byte, error)
	ListFiles(ctx context.Context, path string) ([]api.FileInfo, error)
	AddAllowedHosts(ctx context.Context, hosts []string) ([]string, error)
	RemoveAllowedHosts(ctx context.Context, hosts []string) ([]string, error)
	AllowedHosts(ctx context.Context) ([]string, error)
	Events() <-chan api.Event
	Close(ctx context.Context) error
}

type VMFactory

type VMFactory func(ctx context.Context, config *api.Config) (VM, error)

Jump to

Keyboard shortcuts

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