ipc

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 14 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 ipc implements the stdio JSON-RPC protocol between the Tauri shell and the sidecar.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterConfigHandlers

func RegisterConfigHandlers(s *Server, store *storage.Client, onChange OnConfigChange)

RegisterConfigHandlers wires config.get and config.update.

func RegisterCoreHandlers

func RegisterCoreHandlers(s *Server)

RegisterCoreHandlers wires methods that don't depend on storage.

func RegisterOutageHandlers

func RegisterOutageHandlers(s *Server, store *storage.Client)

RegisterOutageHandlers wires outages.list. Defaults to the last 7 days.

func RegisterReportHandlers

func RegisterReportHandlers(s *Server, store *storage.Client)

RegisterReportHandlers wires report.generate.

func RegisterSampleHandlers

func RegisterSampleHandlers(s *Server, store *storage.Client)

RegisterSampleHandlers wires samples.query. See pickGranularity for auto-resolution rules.

func RegisterTargetHandlers

func RegisterTargetHandlers(s *Server, store *storage.Client, onDisabled OnTargetDisabled)

RegisterTargetHandlers wires targets.list/create/update/delete.

Pass onDisabled=nil to skip the open-outage closure side-effect.

func RegisterWifiHandlers

func RegisterWifiHandlers(s *Server, store *storage.Client)

RegisterWifiHandlers wires wifi.list.

Types

type Error

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

Error is an RPC-style structured error.

type Event

type Event struct {
	Event string `json:"event"`
	Data  any    `json:"data,omitempty"`
}

Event is an unsolicited message from the sidecar (no id, distinguishes from Response).

Tauri 2 event names: alphanumerics + `-/:_` only. Use `:` for namespacing; `.` silently drops.

type GatewayInfo added in v0.1.1

type GatewayInfo struct {
	IP       string `json:"ip,omitempty"`
	Detected bool   `json:"detected"`
}

GatewayInfo is the payload returned by system.gateway.

type Handler

type Handler func(ctx context.Context, params json.RawMessage) (any, *Error)

Handler is the signature every IPC method implements.

type HealthCheckResult

type HealthCheckResult struct {
	Status  string `json:"status"`
	Version string `json:"version"`
	Commit  string `json:"commit,omitempty"`
}

HealthCheckResult is the payload returned by health.check.

type OnConfigChange

type OnConfigChange func(cfg storage.AppConfig)

OnConfigChange fires after a successful config.update. Free function type to avoid a monitor → ipc import cycle.

type OnTargetDisabled added in v0.1.2

type OnTargetDisabled func(scope string)

OnTargetDisabled fires after a successful targets.update that flips a target from enabled to disabled. Lets the app layer close any open outage rows for the target's scope — a disabled probe produces no more samples, so the normal recovery hold-off can't fire.

type Request

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

Request is an inbound method call from the Tauri shell.

type Response

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

Response is the reply to a Request. Exactly one of Result or Error is set.

type SamplesQueryResponse

type SamplesQueryResponse struct {
	Granularity string `json:"granularity"`
	Rows        any    `json:"rows"`
}

SamplesQueryResponse tags rows with their granularity so the frontend knows the row shape. Rows is []storage.Sample when granularity=="raw", otherwise []storage.AggregatedRow.

type Server

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

Server dispatches JSON-RPC requests read from in and writes responses + events to out.

func NewServer

func NewServer(in io.Reader, out io.Writer) *Server

NewServer constructs an IPC server bound to the given streams.

func (*Server) Emit

func (s *Server) Emit(event string, data any)

Emit sends an unsolicited event to the Tauri shell. Safe from any goroutine.

func (*Server) Register

func (s *Server) Register(method string, handler Handler)

Register binds method to handler. Not thread-safe — call before Run.

func (*Server) Run

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

Run reads requests until ctx is canceled or in hits EOF. Each request is dispatched on its own goroutine.

Jump to

Keyboard shortcuts

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