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 ¶
- func ChannelsCommand() *ucli.Command
- func DLQCommand() *ucli.Command
- func KeysCommand() *ucli.Command
- func LoginCommand() *ucli.Command
- func LogoutCommand() *ucli.Command
- func ParseRateLimits(pubRate string, pubBurst int, subRate string, subBurst int, tokRate string, ...) (ratelimit.RateLimits, error)
- func ParseRateSpec(spec string, burst int) (ratelimit.Limit, error)
- func PublishCommand() *ucli.Command
- func ReadCredentials() string
- func ServeCommand() *ucli.Command
- func SetVersion(v string)
- func SubscribeCommand() *ucli.Command
- func TokensCommand() *ucli.Command
- func Version() string
- func WriteManifest(ctx context.Context, w io.Writer) error
- type PeerNotifyResult
- type RevokeSummary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChannelsCommand ¶
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 ¶
DLQCommand groups dead-letter queue management subcommands. Every route goes through the management RPC so the server is the single writer.
func KeysCommand ¶
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 ¶
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:
- Fetch the issuer's discovery document to find the device-authorization endpoint and token endpoint.
- POST to device-authorization with the configured client_id; receive a user_code, verification_uri, device_code, interval.
- Print user_code + verification_uri so the operator can complete the flow in a browser.
- Poll the token endpoint at `interval` until the operator approves (status: success) or the device_code expires.
- Persist the resulting ID token to ~/.parsec/credentials (0600) so subsequent `parsec --token` invocations pick it up via the Token() helper.
func LogoutCommand ¶
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 ¶
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 ¶
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 ¶
ServeCommand boots the embedded centrifuge broker and the HTTP surface (websocket + twirp + healthz).
func SubscribeCommand ¶
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.
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.