ipc

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindRunningSocket

func FindRunningSocket(appName string) (string, error)

func Respond

func Respond[T any](w *ConnWriter, id int, result T)

func RespondError

func RespondError(w *ConnWriter, id int, msg string)

Types

type Capabilities

type Capabilities struct {
	APIVersion   int      `json:"apiVersion"`
	Capabilities []string `json:"capabilities"`
}

type Client

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

func Dial

func Dial(socketPath string) (*Client, error)

func (*Client) Call

func (c *Client) Call(req Request) (*Response[any], error)

func (*Client) Close

func (c *Client) Close() error

type Config

type Config struct {
	AppName                string
	APIVersion             int
	Capabilities           []string
	CapabilitiesFunc       func() []string // computed per connection; overrides Capabilities when set
	MaxLineSize            int
	DefaultSubscribeTopics []string
	OnSubscribe            func(topics []string, sub *Subscriber)
	SubscribeHandler       Handler // replaces the built-in subscribe/unsubscribe handling when set
	Bus                    *EventBus
}

type ConnWriter

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

func NewConnWriter

func NewConnWriter(conn net.Conn) *ConnWriter

func (*ConnWriter) WriteEvent

func (w *ConnWriter) WriteEvent(ev Event) error

func (*ConnWriter) WriteResponse

func (w *ConnWriter) WriteResponse(resp any) error

type Event

type Event struct {
	Topic string
	Data  any
}

type EventBus

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

func NewEventBus

func NewEventBus() *EventBus

func (*EventBus) HasSubscriber

func (b *EventBus) HasSubscriber(topic string) bool

func (*EventBus) NewSubscriber

func (b *EventBus) NewSubscriber(ctx context.Context, writer *ConnWriter) *Subscriber

func (*EventBus) Publish

func (b *EventBus) Publish(topic string, data any)

type Handler

type Handler func(ctx context.Context, w *ConnWriter, req Request, sub *Subscriber)

type Mux

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

func NewMux

func NewMux() *Mux

func (*Mux) Handle

func (m *Mux) Handle(method string, h Handler)

func (*Mux) HandlePrefix

func (m *Mux) HandlePrefix(prefix string, h Handler)

func (*Mux) ServeIPC

func (m *Mux) ServeIPC(ctx context.Context, w *ConnWriter, req Request, sub *Subscriber)

type Request

type Request struct {
	ID     int            `json:"id,omitempty"`
	Method string         `json:"method"`
	Params map[string]any `json:"params,omitempty"`
}

type Response

type Response[T any] struct {
	ID     int    `json:"id,omitempty"`
	Result *T     `json:"result,omitempty"`
	Error  string `json:"error,omitempty"`
}

type Server

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

func NewServer

func NewServer(cfg Config, handler Handler) *Server

func (*Server) Bus

func (s *Server) Bus() *EventBus

func (*Server) Close

func (s *Server) Close() error

func (*Server) Listen

func (s *Server) Listen() error

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

func (*Server) Serve

func (s *Server) Serve(ctx context.Context) error

func (*Server) Shutdown

func (s *Server) Shutdown(context.Context) error

func (*Server) SocketPath

func (s *Server) SocketPath() string

type Subscriber

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

func (*Subscriber) Close

func (s *Subscriber) Close()

func (*Subscriber) Subscribe

func (s *Subscriber) Subscribe(topics ...string)

func (*Subscriber) Topics

func (s *Subscriber) Topics() []string

func (*Subscriber) Unsubscribe

func (s *Subscriber) Unsubscribe(topics ...string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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