Documentation
¶
Index ¶
- func NewEntitlementGrantOwnerAdapter(featureRepo productcatalog.FeatureRepo, ...) credit.OwnerConnector
- type BalanceHistoryParams
- type Connector
- type CreateEntitlementGrantInputs
- type Entitlement
- type EntitlementBalance
- type EntitlementBalanceHistoryWindow
- type EntitlementGrant
- type MeteredEntitlementValue
- type ResetEntitlementUsageParams
- type UsageResetNotFoundError
- type UsageResetRepo
- type UsageResetTime
- type WindowSize
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEntitlementGrantOwnerAdapter ¶
func NewEntitlementGrantOwnerAdapter( featureRepo productcatalog.FeatureRepo, entitlementRepo entitlement.EntitlementRepo, usageResetRepo UsageResetRepo, meterRepo meter.Repository, logger *slog.Logger, ) credit.OwnerConnector
Types ¶
type BalanceHistoryParams ¶
type Connector ¶
type Connector interface { entitlement.SubTypeConnector GetEntitlementBalance(ctx context.Context, entitlementID models.NamespacedID, at time.Time) (*EntitlementBalance, error) GetEntitlementBalanceHistory(ctx context.Context, entitlementID models.NamespacedID, params BalanceHistoryParams) ([]EntitlementBalanceHistoryWindow, credit.GrantBurnDownHistory, error) ResetEntitlementUsage(ctx context.Context, entitlementID models.NamespacedID, params ResetEntitlementUsageParams) (balanceAfterReset *EntitlementBalance, err error) ResetEntitlementsWithExpiredUsagePeriod(ctx context.Context, namespace string, highwatermark time.Time) ([]models.NamespacedID, error) // GetEntitlementGrantBalanceHistory(ctx context.Context, entitlementGrantID EntitlementGrantID, params BalanceHistoryParams) ([]EntitlementBalanceHistoryWindow, error) CreateGrant(ctx context.Context, entitlement models.NamespacedID, inputGrant CreateEntitlementGrantInputs) (EntitlementGrant, error) ListEntitlementGrants(ctx context.Context, entitlementID models.NamespacedID) ([]EntitlementGrant, error) }
func NewMeteredEntitlementConnector ¶
func NewMeteredEntitlementConnector( streamingConnector streaming.Connector, ownerConnector credit.OwnerConnector, balanceConnector credit.BalanceConnector, grantConnector credit.GrantConnector, entitlementRepo entitlement.EntitlementRepo, ) Connector
type CreateEntitlementGrantInputs ¶
type CreateEntitlementGrantInputs struct {
credit.CreateGrantInput
}
type Entitlement ¶
type Entitlement struct { entitlement.GenericProperties // MeasureUsageFrom defines the time from which usage should be measured. // This is a global value, in most cases the same value as `CreatedAt` should be fine. MeasureUsageFrom time.Time `json:"measureUsageFrom,omitempty"` // IssueAfterReset defines an amount of usage that will be issued after a reset. // This affordance will only be usable until the next reset. IssuesAfterReset *float64 `json:"issueAfterReset,omitempty"` // IsSoftLimit defines if the entitlement is a soft limit. By default when balance falls to 0 // access will be disabled. If this is a soft limit, access will be allowed nonetheless. IsSoftLimit bool `json:"isSoftLimit,omitempty"` // UsagePeriod defines the recurring period for usage calculations. UsagePeriod entitlement.UsagePeriod `json:"usagePeriod,omitempty"` // CurrentPeriod defines the current period for usage calculations. CurrentUsagePeriod recurrence.Period `json:"currentUsagePeriod,omitempty"` // LastReset defines the last time the entitlement was reset. LastReset time.Time `json:"lastReset"` }
func ParseFromGenericEntitlement ¶
func ParseFromGenericEntitlement(model *entitlement.Entitlement) (*Entitlement, error)
type EntitlementBalance ¶
type EntitlementGrant ¶
type EntitlementGrant struct { credit.Grant // "removing" fields OwnerID string `json:"-"` ResetMaxRollover float64 `json:"-"` // "adding" fields EntitlementID string `json:"entitlementId"` NextRecurrence *time.Time `json:"nextRecurrence,omitempty"` MaxRolloverAmount float64 `json:"maxRolloverAmount"` }
func GrantFromCreditGrant ¶
func GrantFromCreditGrant(grant credit.Grant) (*EntitlementGrant, error)
type MeteredEntitlementValue ¶
type MeteredEntitlementValue struct { Balance float64 `json:"balance"` UsageInPeriod float64 `json:"usageInPeriod"` Overage float64 `json:"overage"` StartOfPeriod time.Time `json:"startOfPeriod"` // contains filtered or unexported fields }
func (*MeteredEntitlementValue) HasAccess ¶
func (m *MeteredEntitlementValue) HasAccess() bool
type UsageResetNotFoundError ¶
type UsageResetNotFoundError struct {
EntitlementID models.NamespacedID
}
func (UsageResetNotFoundError) Error ¶
func (e UsageResetNotFoundError) Error() string
type UsageResetRepo ¶
type UsageResetRepo interface { Save(ctx context.Context, usageResetTime UsageResetTime) error GetLastAt(ctx context.Context, entitlementID models.NamespacedID, at time.Time) (*UsageResetTime, error) GetBetween(ctx context.Context, entitlementID models.NamespacedID, from time.Time, to time.Time) ([]UsageResetTime, error) entutils.TxCreator entutils.TxUser[UsageResetRepo] }
type UsageResetTime ¶
type UsageResetTime struct { models.NamespacedModel ResetTime time.Time EntitlementID string }
type WindowSize ¶
type WindowSize string
const ( // We don't support minute precision as that results in an extremely heavy calculation // WindowSizeMinute WindowSize = "MINUTE" WindowSizeHour WindowSize = "HOUR" WindowSizeDay WindowSize = "DAY" )
Click to show internal directories.
Click to hide internal directories.