Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SortedPeriodsFromDedupedTimes ¶
func SortedPeriodsFromDedupedTimes(ts []time.Time) []recurrence.Period
Returns a list of non-overlapping periods between the sorted times.
Types ¶
type BalanceConnector ¶
type BalanceConnector interface {
GetBalanceOfOwner(ctx context.Context, owner grant.NamespacedOwner, at time.Time) (*balance.Snapshot, error)
GetBalanceHistoryOfOwner(ctx context.Context, owner grant.NamespacedOwner, params BalanceHistoryParams) (engine.GrantBurnDownHistory, error)
ResetUsageForOwner(ctx context.Context, owner grant.NamespacedOwner, params ResetUsageForOwnerParams) (balanceAfterReset *balance.Snapshot, err error)
}
Generic connector for balance related operations.
type CreateGrantInput ¶
type CreateGrantInput struct {
Amount float64
Priority uint8
EffectiveAt time.Time
Expiration grant.ExpirationPeriod
Metadata map[string]string
ResetMaxRollover float64
ResetMinRollover float64
Recurrence *recurrence.Recurrence
}
type CreditConnector ¶
type CreditConnector interface {
BalanceConnector
GrantConnector
}
func NewCreditConnector ¶
func NewCreditConnector( grantRepo grant.Repo, balanceSnapshotRepo balance.SnapshotRepo, ownerConnector grant.OwnerConnector, streamingConnector streaming.Connector, logger *slog.Logger, granularity time.Duration, publisher eventbus.Publisher, ) CreditConnector
type GrantConnector ¶
type GrantConnector interface {
CreateGrant(ctx context.Context, owner grant.NamespacedOwner, grant CreateGrantInput) (*grant.Grant, error)
VoidGrant(ctx context.Context, grantID models.NamespacedID) error
}
type GrantNotFoundError ¶
type GrantNotFoundError struct {
GrantID string
}
func (*GrantNotFoundError) Error ¶
func (e *GrantNotFoundError) Error() string
Click to show internal directories.
Click to hide internal directories.