Documentation
¶
Index ¶
- Constants
- type Config
- type FeatureFlags
- type Handler
- func (h *Handler) HandleCancelledEvent(ctx context.Context, event *subscription.CancelledEvent) error
- func (h *Handler) HandleInvoiceCreation(ctx context.Context, invoice billing.EventInvoice) error
- func (h *Handler) HandleSubscriptionCreated(ctx context.Context, subs subscription.SubscriptionView, asOf time.Time) error
- func (h *Handler) SyncronizeSubscription(ctx context.Context, subs subscription.SubscriptionView, asOf time.Time) error
- type PhaseIterator
- func (it *PhaseIterator) Generate(iterationEnd time.Time) ([]subscriptionItemWithPeriod, error)
- func (it *PhaseIterator) GetMinimumBillableTime() time.Time
- func (it *PhaseIterator) HasInvoicableItems() bool
- func (it *PhaseIterator) PhaseEnd() *time.Time
- func (it *PhaseIterator) PhaseStart() time.Time
- type Reconciler
- func (r *Reconciler) All(ctx context.Context, in ReconcilerAllInput) error
- func (r *Reconciler) ListSubscriptions(ctx context.Context, in ReconcilerListSubscriptionsInput) ([]subscription.Subscription, error)
- func (r *Reconciler) ReconcileSubscription(ctx context.Context, subsID models.NamespacedID) error
- type ReconcilerAllInput
- type ReconcilerConfig
- type ReconcilerListSubscriptionsInput
Constants ¶
const (
SubscriptionSyncComponentName billing.ComponentName = "subscription-sync"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
BillingService billing.Service
SubscriptionService subscription.Service
TxCreator transaction.Creator
Logger *slog.Logger
FeatureFlags FeatureFlags
}
type FeatureFlags ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) HandleCancelledEvent ¶
func (h *Handler) HandleCancelledEvent(ctx context.Context, event *subscription.CancelledEvent) error
HandleCancelledEvent is a handler for the subscription cancel event, it will make sure that we syncronize the
func (*Handler) HandleInvoiceCreation ¶
HandleInvoiceCreation is a handler for the invoice creation event, it will make sure that we are backfilling the items consumed by invoice creation into the gathering invoice.
func (*Handler) HandleSubscriptionCreated ¶
func (h *Handler) HandleSubscriptionCreated(ctx context.Context, subs subscription.SubscriptionView, asOf time.Time) error
func (*Handler) SyncronizeSubscription ¶
func (h *Handler) SyncronizeSubscription(ctx context.Context, subs subscription.SubscriptionView, asOf time.Time) error
type PhaseIterator ¶
type PhaseIterator struct {
// contains filtered or unexported fields
}
func NewPhaseIterator ¶
func NewPhaseIterator(subs subscription.SubscriptionView, phaseKey string) (*PhaseIterator, error)
func (*PhaseIterator) Generate ¶
func (it *PhaseIterator) Generate(iterationEnd time.Time) ([]subscriptionItemWithPeriod, error)
func (*PhaseIterator) GetMinimumBillableTime ¶
func (it *PhaseIterator) GetMinimumBillableTime() time.Time
GetMinimumBillableTime returns the minimum time that we can bill for the phase (e.g. the first time we would be yielding a line item)
func (*PhaseIterator) HasInvoicableItems ¶
func (it *PhaseIterator) HasInvoicableItems() bool
func (*PhaseIterator) PhaseEnd ¶
func (it *PhaseIterator) PhaseEnd() *time.Time
func (*PhaseIterator) PhaseStart ¶
func (it *PhaseIterator) PhaseStart() time.Time
type Reconciler ¶
type Reconciler struct {
// contains filtered or unexported fields
}
Reconciler is a component that periodically reconciles the subscription state with the billing state this is essential, as the invoice creation is purley event driven. In case a processing error happens, we might fail to create an invoice, and stop processing the subscription.
func NewReconciler ¶
func NewReconciler(config ReconcilerConfig) (*Reconciler, error)
func (*Reconciler) All ¶
func (r *Reconciler) All(ctx context.Context, in ReconcilerAllInput) error
func (*Reconciler) ListSubscriptions ¶
func (r *Reconciler) ListSubscriptions(ctx context.Context, in ReconcilerListSubscriptionsInput) ([]subscription.Subscription, error)
func (*Reconciler) ReconcileSubscription ¶
func (r *Reconciler) ReconcileSubscription(ctx context.Context, subsID models.NamespacedID) error
type ReconcilerAllInput ¶
type ReconcilerAllInput = ReconcilerListSubscriptionsInput
type ReconcilerConfig ¶
type ReconcilerConfig struct {
SubscriptionSync *Handler
SubscriptionService subscription.Service
CustomerService customer.Service
Logger *slog.Logger
}
func (ReconcilerConfig) Validate ¶
func (c ReconcilerConfig) Validate() error
type ReconcilerListSubscriptionsInput ¶
type ReconcilerListSubscriptionsInput struct {
Namespaces []string
Customers []string
Lookback time.Duration
}
func (ReconcilerListSubscriptionsInput) Validate ¶
func (i ReconcilerListSubscriptionsInput) Validate() error