rpcserver

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package rpcserver serves the notesd API on lodge's kit (github.com/frostyard/lodge/kit/jsonrpc): rpc.hello, events.subscribe and a caller identity per connection. The kit does the framing, the gating on rpc.hello, concurrent dispatch, panics and oversized replies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Name is reported by rpc.hello, e.g. "notesd v0.1.0".
	Name   string
	Broker *events.Broker
	Logger *slog.Logger
	// Build is reported by rpc.hello as build: the Flatpak build notesd runs
	// from. Empty means none (outside the Flatpak, or unknown).
	Build string
	// Shutdown stops notesd, as SIGTERM does (rpc.shutdown). It must return
	// at once: the server calls it after the reply is on the wire, from the
	// request's own goroutine, which Serve waits for. Nil means a call cannot
	// stop this server, and rpc.shutdown answers unavailable.
	Shutdown func()
	// Panics records a panic of a request's handler in the journal before
	// the kit answers internal, as it does without it
	// (docs/adr/0036-notesd-and-the-app-record-problems-in-the-journal.md).
	// Nil records nothing.
	Panics *problems.Recorder
}

Options configures a Server.

type Server

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

Server implements api.RPCService and api.EventsService, which need the connection, and serves a Router built with them.

func New

func New(opts Options) *Server

New returns a Server.

func (*Server) Hello

func (s *Server) Hello(ctx context.Context, p *api.RPCHelloParams) (*api.Hello, error)

Hello implements rpc.hello.

func (*Server) Listen

func (s *Server) Listen(path string) (net.Listener, error)

Listen creates notesd's private socket (jsonrpc.ListenWith).

func (*Server) Ping

Ping implements rpc.ping.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, ln net.Listener, r *api.Router) error

Serve accepts connections on notesd's socket until ctx ends, then waits for them to finish. Each serves api.CallerLocal.

func (*Server) ServeConn

func (s *Server) ServeConn(ctx context.Context, nc net.Conn, r *api.Router, id api.Identity)

ServeConn serves one connection that its listener has already authenticated as id (the development gateway, and lodge's sessions and agents) until it ends or ctx does.

func (*Server) Shutdown added in v0.3.0

func (s *Server) Shutdown(ctx context.Context, _ *api.RPCShutdownParams) error

Shutdown implements rpc.shutdown: the reply goes out first, then Options.Shutdown runs (jsonrpc.AfterReply), so the caller has its answer before notesd stops. A call that fails never stops notesd.

func (*Server) Subscribe

Subscribe implements events.subscribe; delivery starts after the reply.

Jump to

Keyboard shortcuts

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