managedstream

package
v0.10.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	SchemaVersion   = "authorization-ledger-v1"
	DefaultEndpoint = "/api/v1/authorization-ledger/batches"

	DefaultBatchLimit        = 100
	MaxPayloadBytes          = 192 * 1024
	DefaultInterval          = 10 * time.Second
	DefaultHeartbeatInterval = 60 * time.Second
)

Variables

This section is empty.

Functions

func AuthFailureStatus added in v0.10.0

func AuthFailureStatus(err error) (int, bool)

func DefaultIntervalFromEnv

func DefaultIntervalFromEnv() time.Duration

func DefaultStatePath

func DefaultStatePath() string

func DefaultStatePathForDB

func DefaultStatePathForDB(dbPath string) string

func Flush

func Flush(ctx context.Context, opts Options) error

func SaveState

func SaveState(path string, state State) error

func ShouldReportAuthFailure added in v0.10.0

func ShouldReportAuthFailure(consecutiveFailures int) bool

Types

type Device

type Device struct {
	Label             string `json:"label,omitempty"`
	DeploymentVersion string `json:"deployment_version,omitempty"`
}

type Options

type Options struct {
	DBPath            string
	StatePath         string
	CloudURL          string
	InstallationID    string
	InstallToken      string
	DeviceLabel       string
	DeploymentVersion func() string
	Interval          time.Duration
	HeartbeatInterval time.Duration
	BatchLimit        int
	HTTPClient        *http.Client
	Diagnostic        diagnostic.Logger
	// 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"`
}

type State

type State struct {
	UpdatedAfter           *time.Time
	ActionID               string
	LastHeartbeatAttemptAt string
	LastHeartbeatAt        string
}

func LoadState

func LoadState(path string) (State, error)

Jump to

Keyboard shortcuts

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