Documentation
¶
Overview ¶
Package tiered is an optional visibility policy: it maps an item's level to entitlement keys and asks a Checker which ones the actor holds. It imports no billing client; a host adapts OpenRails in one expression:
checker := tiered.CheckerFunc(func(ctx context.Context, subject string, keys []string) (map[string]bool, error) {
return client.CheckEntitlements(ctx, subject, keys, time.Time{}) // at most openrails.MaxEntitlementChecks keys
})
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrPolicy = errors.New("tiered: invalid policy")
ErrPolicy reports a policy with an unknown level or a missing required key.
Functions ¶
Types ¶
type Checker ¶
type Checker interface {
Check(ctx context.Context, subject string, keys []string) (map[string]bool, error)
}
Checker reports which of keys the subject holds. Missing keys are not held.
type CheckerFunc ¶
CheckerFunc adapts a function to Checker.
type Policy ¶
type Policy struct {
Level Level
Membership string // e.g. "channel:{id}:membership"
Purchase string // e.g. "post:{billing key}"
Premium string // e.g. "site:premium"
}
Policy is one item's level and the host's entitlement keys for it. A purchase is ownership: a set Purchase key grants every paid level, so a buyer keeps access after the level or their membership changes.
Click to show internal directories.
Click to hide internal directories.