cli

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package cli holds the urfave/cli/v3 command definitions for the parsec binary. cmd/parsec/main.go is a thin assembler; the bodies live here so they are testable without spawning processes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChannelsCommand

func ChannelsCommand() *ucli.Command

ChannelsCommand groups channel-management subcommands. Each one is a thin wrapper over the Twirp client; the CLI cannot do anything the bearer account cannot do.

func DLQCommand

func DLQCommand() *ucli.Command

DLQCommand groups dead-letter queue management subcommands. Every route goes through the management RPC so the server is the single writer.

func KeysCommand

func KeysCommand() *ucli.Command

KeysCommand groups key rotation subcommands. Most routes hit the management RPC — the CLI never edits keyring.json directly. That keeps the server the single writer and avoids two-writer file races.

`keys export` and `keys import` are the exception: they operate directly against the local KeyRingStore so multi-region operators can shuttle a snapshot between regions without a live RPC route between them. The store is the single writer for the region; export/import touch it from the same host that runs parsec.

func LoginCommand

func LoginCommand() *ucli.Command

LoginCommand groups OIDC-based login flows. Today the only supported provider is generic OIDC via the device-authorization grant — the IdP must implement RFC 8628.

The flow:

  1. Fetch the issuer's discovery document to find the device-authorization endpoint and token endpoint.
  2. POST to device-authorization with the configured client_id; receive a user_code, verification_uri, device_code, interval.
  3. Print user_code + verification_uri so the operator can complete the flow in a browser.
  4. Poll the token endpoint at `interval` until the operator approves (status: success) or the device_code expires.
  5. Persist the resulting ID token to ~/.parsec/credentials (0600) so subsequent `parsec --token` invocations pick it up via the Token() helper.

func LogoutCommand

func LogoutCommand() *ucli.Command

LogoutCommand removes the persisted credentials file.

func ParseRateLimits

func ParseRateLimits(pubRate string, pubBurst int, subRate string, subBurst int, tokRate string, tokBurst int) (ratelimit.RateLimits, error)

ParseRateLimits assembles a ratelimit.RateLimits from the operator- friendly "N/<window>" shorthand. window is one of "s", "m", "h" (or any duration go parses) — "100/s" is "100 events per second". An empty rate string disables that bucket. burst <= 0 means "default to rate" (no burst above the steady-state).

Returns an error when a spec is malformed so the CLI fails loud rather than booting with a silently-misconfigured limiter.

func ParseRateSpec

func ParseRateSpec(spec string, burst int) (ratelimit.Limit, error)

ParseRateSpec parses a single rate spec "N/<window>" into a ratelimit.Limit. Empty input returns the zero Limit (unlimited). Burst <= 0 falls back to the rate.

Accepted windows: any duration form parseable by time.ParseDuration, plus the bare aliases "s" (=1s), "m" (=1m), "h" (=1h).

func PublishCommand

func PublishCommand() *ucli.Command

PublishCommand sends a message to a channel via the remote server. Body is read from --data, --file, or stdin (in that order of preference).

func ReadCredentials

func ReadCredentials() string

ReadCredentials returns the persisted OIDC ID token, or "" when no credentials file exists. Exposed for the CLI's --token resolution helper.

func ServeCommand

func ServeCommand() *ucli.Command

ServeCommand boots the embedded centrifuge broker and the HTTP surface (websocket + twirp + healthz).

func SetVersion

func SetVersion(v string)

SetVersion is called from main.

func SubscribeCommand

func SubscribeCommand() *ucli.Command

SubscribeCommand is intentionally lightweight: it subscribes to the configured channel and streams every received Publication as a one-line JSON envelope to stdout. It is useful as a probe; production consumers should embed the library or use a websocket client directly.

func TokensCommand

func TokensCommand() *ucli.Command

TokensCommand groups token operations.

func Version

func Version() string

Version returns the build-time version string.

func WriteManifest

func WriteManifest(ctx context.Context, w io.Writer) error

WriteManifest prints the manifest envelope to w. Used by both the root `--json` flag and the dedicated `manifest` resource.

Types

type PeerNotifyResult

type PeerNotifyResult struct {
	URL    string `json:"url"`
	Status int    `json:"status,omitempty"`
	OK     bool   `json:"ok"`
	Error  string `json:"error,omitempty"`
}

PeerNotifyResult records the outcome of a single peer ReloadKeys POST. Surfaced in the `keys retire --notify` envelope so operators can spot the region that drifted.

type RevokeSummary added in v0.3.0

type RevokeSummary struct {
	TokenID string `json:"token_id,omitempty"`
	UserID  string `json:"user_id,omitempty"`
	Reason  string `json:"reason,omitempty"`
}

RevokeSummary is the descriptor payload for a successful revoke.

Jump to

Keyboard shortcuts

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