ipc

package
v1.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHostAlreadyRunning = errors.New("host already running")

ErrHostAlreadyRunning is returned when another host is already listening.

Functions

func CleanStaleSocket

func CleanStaleSocket()

CleanStaleSocket removes the socket file if no host is listening.

func Dial

func Dial() (net.Conn, error)

Dial connects to the host process with a timeout.

func IsHostRunning

func IsHostRunning() bool

IsHostRunning checks if a host process is listening on the socket.

func SocketPath

func SocketPath() string

SocketPath returns the Unix socket path for IPC, scoped to the current user.

Types

type Handler

type Handler func(req OpenRequest) OpenResponse

Handler is called when a new open request arrives from a CLI client.

type OpenRequest

type OpenRequest struct {
	ConfigPath string `json:"config_path"`
}

OpenRequest is sent from CLI to host to open a new window.

type OpenResponse

type OpenResponse struct {
	OK       bool   `json:"ok"`
	WindowID string `json:"window_id,omitempty"`
	Error    string `json:"error,omitempty"`
	Reused   bool   `json:"reused,omitempty"`
}

OpenResponse is sent from host back to CLI.

func SendOpen

func SendOpen(conn net.Conn, cfgPath string) (OpenResponse, error)

SendOpen sends an open request to the host and reads the response.

type Server

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

Server listens on a Unix socket for IPC requests from CLI processes.

func NewServer

func NewServer(handler Handler) (*Server, error)

NewServer creates a new IPC server that forwards requests to handler. Uses try-listen-first to avoid races between concurrent host spawns.

func (*Server) Close

func (s *Server) Close()

Close stops the server and removes the socket file.

func (*Server) Serve

func (s *Server) Serve()

Serve accepts connections until Close is called.

func (*Server) Wait

func (s *Server) Wait()

Wait blocks until the server has stopped.

Jump to

Keyboard shortcuts

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