Documentation
¶
Overview ¶
Package contribution manages voluntary storage consent without holding provider credentials.
Index ¶
- Variables
- func OwnerDomain(p Principal) string
- type Access
- type Authorizer
- type CommandRequest
- type Conditions
- type Config
- type Consent
- type CreateRequest
- type Event
- type EventData
- type Job
- type Observation
- type Page
- type Policy
- type Principal
- type Record
- type Replay
- type Repository
- type RetryRequest
- type Service
- func (s *Service) Command(ctx context.Context, p Principal, id, key string, q CommandRequest) (View, error)
- func (s *Service) Create(ctx context.Context, p Principal, key string, q CreateRequest) (View, error)
- func (s *Service) Get(ctx context.Context, p Principal, id string) (View, error)
- func (s *Service) List(ctx context.Context, p Principal, n int, after string) (Page, error)
- func (s *Service) Operations(ctx context.Context, p Principal, n int, after string) (Page, error)
- func (s *Service) Options(ctx context.Context, p Principal, n int, after string) (storage.ContributionCandidates, error)
- func (s *Service) Policy() Policy
- func (s *Service) RetryOperation(ctx context.Context, p Principal, id, key string, q RetryRequest) (View, error)
- func (s *Service) RunOne(ctx context.Context, worker string) error
- func (s *Service) Statistics(ctx context.Context) (Statistics, error)
- func (s *Service) Sweep(ctx context.Context, n int, after string) (string, error)
- type Statistics
- type Store
- type Terms
- type Transaction
- type View
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func OwnerDomain ¶
OwnerDomain is the stable storage ownership binding, including identity issuer.
Types ¶
type Authorizer ¶
type CommandRequest ¶
type CommandRequest struct {
Revision int64 `json:"revision"`
Action string `json:"action"`
Conditions *Conditions `json:"conditions,omitempty"`
Consent *Consent `json:"consent,omitempty"`
}
type Conditions ¶
type CreateRequest ¶
type CreateRequest struct {
InstanceID string `json:"instance_id"`
Conditions Conditions `json:"conditions"`
Consent Consent `json:"consent"`
}
type Event ¶
type Event struct {
SpecVersion string `json:"specversion"`
Source string `json:"source"`
ID string `json:"id"`
Type string `json:"type"`
Subject string `json:"subject"`
Time time.Time `json:"time"`
DataContentType string `json:"datacontenttype"`
Data EventData `json:"data"`
Actor Principal `json:"-"`
}
type Observation ¶
type Observation struct {
ObservedAt time.Time `json:"observed_at"`
AuthorizationExpiresAt time.Time `json:"authorization_expires_at"`
QuotaExpiresAt time.Time `json:"quota_expires_at"`
Authorized bool `json:"authorized"`
UsedBytes int64 `json:"used_bytes"`
ReservedBytes int64 `json:"reserved_bytes"`
AvailableBytes int64 `json:"available_bytes"`
RemainingReplicas int64 `json:"remaining_replicas"`
}
type Policy ¶
type Policy struct {
Terms Terms `json:"terms"`
Adapters []string `json:"adapters"`
MinBytes int64 `json:"min_bytes"`
MaxBytes int64 `json:"max_bytes"`
MinTermSeconds int64 `json:"min_term_seconds"`
MaxTermSeconds int64 `json:"max_term_seconds"`
ExitTargetSeconds int64 `json:"exit_target_seconds"`
MaxPerOwner int `json:"max_per_owner"`
ObservationMaxAgeSeconds int64 `json:"observation_max_age_seconds"`
}
type Repository ¶
type RetryRequest ¶
type RetryRequest struct {
Revision int64 `json:"revision"`
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func New ¶
func New(r Repository, a Authorizer, st Store, c Config) (*Service, error)
func (*Service) Operations ¶
func (*Service) Options ¶
func (s *Service) Options(ctx context.Context, p Principal, n int, after string) (storage.ContributionCandidates, error)
Options derives ownership from the verified principal, never a query field.
func (*Service) RetryOperation ¶
func (*Service) Statistics ¶
func (s *Service) Statistics(ctx context.Context) (Statistics, error)
type Statistics ¶
type Statistics struct {
DeclaredBytes int64 `json:"declared_bytes"`
AvailableBytes int64 `json:"available_bytes"`
UsedBytes int64 `json:"used_bytes"`
ReservedBytes int64 `json:"reserved_bytes"`
Contributions int `json:"contributions"`
FreshObservations int `json:"fresh_observations"`
Status string `json:"status"`
GeneratedAt time.Time `json:"generated_at"`
}
type Store ¶
type Store interface {
ListContributionCandidates(context.Context, Principal, string, int, string) (storage.ContributionCandidates, error)
InspectContribution(context.Context, Principal, string, string) (storage.ContributionSnapshot, error)
ApplyContribution(context.Context, Principal, string, storage.ContributionControl) (storage.ContributionSnapshot, error)
}
Store exposes only the provider-independent contribution control boundary.
type Transaction ¶
type Transaction interface {
Lock(string) error
Record(string) (Record, error)
SaveRecord(Record) error
List(Principal, int, string) ([]Record, error)
Scan(int, string) ([]Record, error)
Counts(Principal) (total, owned int, err error)
Job(string) (Job, error)
SaveJob(Job) error
Replay(string) (Replay, error)
SaveReplay(Replay) error
PruneReplays(time.Time, int) error
Event(Event) error
}
Lock order is replay -> record -> job. Claim only locks a job, commits, then starts external work; a storage request never holds a module transaction.
type View ¶
type View struct {
ID string `json:"id"`
Adapter string `json:"adapter"`
Revision int64 `json:"revision"`
AppliedRevision int64 `json:"applied_revision"`
DesiredState string `json:"desired_state"`
State string `json:"state"`
Reason string `json:"reason"`
Conditions Conditions `json:"conditions"`
Consent Terms `json:"consent"`
AcceptedAt time.Time `json:"accepted_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ExitRequestedAt *time.Time `json:"exit_requested_at,omitempty"`
ExitTargetAt *time.Time `json:"exit_target_at,omitempty"`
Observation *Observation `json:"observation,omitempty"`
}
View deliberately omits the principal, provider instance and all custody details.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package httpapi exposes user-owned contribution requests and anonymous aggregate policy.
|
Package httpapi exposes user-owned contribution requests and anonymous aggregate policy. |
|
Package postgres owns contribution metadata and its independent runtime identity.
|
Package postgres owns contribution metadata and its independent runtime identity. |
|
Package sdk provides primitives to interact with the openapi HTTP API.
|
Package sdk provides primitives to interact with the openapi HTTP API. |
Click to show internal directories.
Click to hide internal directories.