socket

package
v0.18.0 Latest Latest
Warning

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

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

Documentation

Overview

Package socket provides a Unix socket server for CLI client queries against the running canopyls LSP server's enriched scope graph.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SocketPath

func SocketPath(workspaceRoot string) string

SocketPath computes the socket path for a workspace root.

Types

type Client

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

Client connects to a running canopyls socket server.

func Dial

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

Dial connects to the canopyls socket for the given workspace.

func (*Client) Call

func (c *Client) Call(method string, params any) (json.RawMessage, error)

Call sends a request and returns the response.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection.

type Handler

type Handler func(params json.RawMessage) (any, error)

Handler processes a socket request.

type Request

type Request struct {
	Method string          `json:"method"`
	Params json.RawMessage `json:"params,omitempty"`
}

Request is a CLI client query.

type Response

type Response struct {
	Result any    `json:"result,omitempty"`
	Error  string `json:"error,omitempty"`
}

Response is the server's reply.

type Server

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

Server listens on a Unix socket and dispatches queries to handlers.

func NewServer

func NewServer(workspaceRoot string, logger *slog.Logger) *Server

NewServer creates a socket server for the given workspace.

func (*Server) Handle

func (s *Server) Handle(method string, h Handler)

Handle registers a handler for a method name.

func (*Server) Path

func (s *Server) Path() string

Path returns the socket file path.

func (*Server) Start

func (s *Server) Start() error

Start begins listening on the Unix socket. Non-blocking — serves in a goroutine.

func (*Server) Stop

func (s *Server) Stop()

Stop closes the socket server.

Jump to

Keyboard shortcuts

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