Documentation
¶
Index ¶
- Constants
- func DefaultIntervalFromEnv() time.Duration
- func DefaultStatePath() string
- func DefaultStatePathForDB(dbPath string) string
- func Flush(ctx context.Context, opts Options) error
- func Run(ctx context.Context, opts Options) error
- func SaveState(path string, state State) error
- type Device
- type Options
- type Payload
- type State
Constants ¶
View Source
const ( SchemaVersion = "authorization-ledger-v1" DefaultEndpoint = "/api/v1/authorization-ledger/batches" DefaultBatchLimit = 100 MaxPayloadBytes = 192 * 1024 DefaultInterval = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func DefaultIntervalFromEnv ¶
func DefaultStatePath ¶
func DefaultStatePath() string
func DefaultStatePathForDB ¶
Types ¶
type Options ¶
type Options struct {
DBPath string
StatePath string
CloudURL string
InstallationID string
InstallToken string
DeviceLabel string
DeploymentVersion func() string
Interval time.Duration
BatchLimit int
HTTPClient *http.Client
Diagnostic diagnostic.Logger
// OnAuthFailure fires (nil-safe) after several consecutive 401/403
// rejections — the signature of a revoked or rotated install token,
// which would otherwise spin silently under launchd. Re-fires
// periodically so a long-running daemon keeps surfacing it without
// spamming every flush.
OnAuthFailure func(status int)
// OnFlushSuccess fires (nil-safe) after every ACCEPTED hosted post, so
// callers can clear "token rejected" breadcrumbs. It deliberately does
// not depend on this process's failure counter (a breadcrumb can outlive
// a daemon restart) and deliberately does NOT fire on empty flushes that
// never contacted the server — an idle machine with a revoked token must
// keep its breadcrumb.
OnFlushSuccess func()
}
type Payload ¶
type Payload struct {
SchemaVersion string `json:"schema_version"`
InstallationID string `json:"installation_id"`
BatchID string `json:"batch_id"`
SentAt string `json:"sent_at"`
Device *Device `json:"device,omitempty"`
Sessions []sqlite.LedgerRecord `json:"agent_sessions"`
Actions []sqlite.LedgerRecord `json:"authorization_actions"`
Receipts []sqlite.LedgerRecord `json:"authorization_receipts"`
ReceiptChainAnchor *sqlite.LedgerReceiptChainAnchor `json:"receipt_chain_anchor,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.