service

package
v1.0.0-beta.231 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config Config) (usagebased.Service, error)

Types

type Config

type Config struct {
	Adapter                 usagebased.Adapter
	Handler                 usagebased.Handler
	Lineage                 lineage.Service
	Locker                  *lockr.Locker
	MetaAdapter             meta.Adapter
	InvoiceUpdater          invoiceupdater.Updater
	CustomerOverrideService billing.CustomerOverrideService
	FeatureService          feature.FeatureConnector
	RatingService           rating.Service

	StreamingConnector streaming.Connector
}

func (Config) Validate

func (c Config) Validate() error

type CreditThenInvoiceStateMachine

type CreditThenInvoiceStateMachine struct {
	// contains filtered or unexported fields
}

func NewCreditThenInvoiceStateMachine

func NewCreditThenInvoiceStateMachine(config StateMachineConfig) (*CreditThenInvoiceStateMachine, error)

func (CreditThenInvoiceStateMachine) AdvanceAfterCollectionPeriodEnd

func (s CreditThenInvoiceStateMachine) AdvanceAfterCollectionPeriodEnd(ctx context.Context) error

func (CreditThenInvoiceStateMachine) AdvanceAfterServicePeriodFrom

func (s CreditThenInvoiceStateMachine) AdvanceAfterServicePeriodFrom(ctx context.Context) error

func (CreditThenInvoiceStateMachine) AdvanceAfterServicePeriodTo

func (s CreditThenInvoiceStateMachine) AdvanceAfterServicePeriodTo(ctx context.Context) error

func (*CreditThenInvoiceStateMachine) AreAllInvoicedRunsSettled

func (s *CreditThenInvoiceStateMachine) AreAllInvoicedRunsSettled() bool

func (*CreditThenInvoiceStateMachine) DeleteCharge

func (s *CreditThenInvoiceStateMachine) DeleteCharge(ctx context.Context, patch meta.PatchDelete) error

func (*CreditThenInvoiceStateMachine) ExtendCharge

func (s *CreditThenInvoiceStateMachine) ExtendCharge(ctx context.Context, patch meta.PatchExtend) error

func (*CreditThenInvoiceStateMachine) FinalizeInvoiceRun

func (*CreditThenInvoiceStateMachine) HasTerminalInvoicedRealizationWithoutCurrentRun

func (s *CreditThenInvoiceStateMachine) HasTerminalInvoicedRealizationWithoutCurrentRun() bool

HasTerminalInvoicedRealizationWithoutCurrentRun lets the active state discover a completed invoice-backed realization after manual period changes. Normally the realization branch moves to settlement when it creates the final run; API gathering-line deletes can instead make an existing paid partial run become final while the charge is already back in active.

func (CreditThenInvoiceStateMachine) IsAfterCollectionPeriod

func (s CreditThenInvoiceStateMachine) IsAfterCollectionPeriod(ctx context.Context, _ ...any) bool

func (CreditThenInvoiceStateMachine) IsAfterServicePeriod

func (s CreditThenInvoiceStateMachine) IsAfterServicePeriod() bool

func (CreditThenInvoiceStateMachine) IsInsideServicePeriod

func (s CreditThenInvoiceStateMachine) IsInsideServicePeriod() bool

func (*CreditThenInvoiceStateMachine) ShrinkCharge

func (s *CreditThenInvoiceStateMachine) ShrinkCharge(ctx context.Context, patch meta.PatchShrink) error

func (*CreditThenInvoiceStateMachine) ShrinkToRealizedPeriod

func (*CreditThenInvoiceStateMachine) SnapshotInvoiceUsage

func (s *CreditThenInvoiceStateMachine) SnapshotInvoiceUsage(ctx context.Context) error

func (*CreditThenInvoiceStateMachine) StartInvoiceRun

func (s *CreditThenInvoiceStateMachine) StartInvoiceRun(
	ctx context.Context,
	input invoiceCreatedInput,
) error

func (CreditThenInvoiceStateMachine) SyncFeatureIDFromFeatureMeter

func (s CreditThenInvoiceStateMachine) SyncFeatureIDFromFeatureMeter(ctx context.Context) error

func (*CreditThenInvoiceStateMachine) UnsupportedExtendOperation

func (s *CreditThenInvoiceStateMachine) UnsupportedExtendOperation(_ context.Context, _ meta.PatchExtend) error

func (*CreditThenInvoiceStateMachine) UnsupportedShrinkOperation

func (s *CreditThenInvoiceStateMachine) UnsupportedShrinkOperation(_ context.Context, _ meta.PatchShrink) error

func (*CreditThenInvoiceStateMachine) UnsupportedShrinkToRealizedPeriodOperation

func (s *CreditThenInvoiceStateMachine) UnsupportedShrinkToRealizedPeriodOperation(_ context.Context, _ meta.PatchShrinkToRealizedPeriod) error

type CreditsOnlyStateMachine

type CreditsOnlyStateMachine struct {
	// contains filtered or unexported fields
}

func NewCreditsOnlyStateMachine

func NewCreditsOnlyStateMachine(config StateMachineConfig) (*CreditsOnlyStateMachine, error)

func (CreditsOnlyStateMachine) AdvanceAfterCollectionPeriodEnd

func (s CreditsOnlyStateMachine) AdvanceAfterCollectionPeriodEnd(ctx context.Context) error

func (CreditsOnlyStateMachine) AdvanceAfterServicePeriodFrom

func (s CreditsOnlyStateMachine) AdvanceAfterServicePeriodFrom(ctx context.Context) error

func (CreditsOnlyStateMachine) AdvanceAfterServicePeriodTo

func (s CreditsOnlyStateMachine) AdvanceAfterServicePeriodTo(ctx context.Context) error

func (*CreditsOnlyStateMachine) ClearAdvanceAfter

func (s *CreditsOnlyStateMachine) ClearAdvanceAfter(ctx context.Context) error

func (*CreditsOnlyStateMachine) DeleteCharge

func (s *CreditsOnlyStateMachine) DeleteCharge(ctx context.Context, patch meta.PatchDelete) error

func (*CreditsOnlyStateMachine) ExtendCharge

func (s *CreditsOnlyStateMachine) ExtendCharge(ctx context.Context, patch meta.PatchExtend) error

func (*CreditsOnlyStateMachine) FinalizeRealizationRun

func (s *CreditsOnlyStateMachine) FinalizeRealizationRun(ctx context.Context) error

func (CreditsOnlyStateMachine) IsAfterCollectionPeriod

func (s CreditsOnlyStateMachine) IsAfterCollectionPeriod(ctx context.Context, _ ...any) bool

func (CreditsOnlyStateMachine) IsAfterServicePeriod

func (s CreditsOnlyStateMachine) IsAfterServicePeriod() bool

func (CreditsOnlyStateMachine) IsInsideServicePeriod

func (s CreditsOnlyStateMachine) IsInsideServicePeriod() bool

func (*CreditsOnlyStateMachine) ShrinkCharge

func (s *CreditsOnlyStateMachine) ShrinkCharge(ctx context.Context, patch meta.PatchShrink) error

func (*CreditsOnlyStateMachine) StartFinalRealizationRun

func (s *CreditsOnlyStateMachine) StartFinalRealizationRun(ctx context.Context) error

func (CreditsOnlyStateMachine) SyncFeatureIDFromFeatureMeter

func (s CreditsOnlyStateMachine) SyncFeatureIDFromFeatureMeter(ctx context.Context) error

type LineEngine

type LineEngine struct {
	// contains filtered or unexported fields
}

func (*LineEngine) BuildStandardInvoiceLines

func (e *LineEngine) BuildStandardInvoiceLines(ctx context.Context, input billing.BuildStandardInvoiceLinesInput) (billing.StandardLines, error)

func (*LineEngine) BuildStandardLinesForGatheringPreview

func (e *LineEngine) BuildStandardLinesForGatheringPreview(ctx context.Context, input billing.BuildStandardInvoiceLinesInput) (billing.StandardLines, error)

func (*LineEngine) GetLineEngineType

func (e *LineEngine) GetLineEngineType() billing.LineEngineType

func (*LineEngine) IsLineBillableAsOf

func (e *LineEngine) IsLineBillableAsOf(_ context.Context, input billing.IsLineBillableAsOfInput) (bool, error)

func (*LineEngine) OnCollectionCompleted

func (e *LineEngine) OnCollectionCompleted(ctx context.Context, input billing.OnCollectionCompletedInput) (billing.StandardLines, error)

func (*LineEngine) OnInvoiceIssued

func (e *LineEngine) OnInvoiceIssued(ctx context.Context, input billing.OnInvoiceIssuedInput) error

func (*LineEngine) OnMutableInvoiceLinesEditedViaAPI

func (e *LineEngine) OnMutableInvoiceLinesEditedViaAPI(ctx context.Context, input billing.OnMutableInvoiceUpdateInput) (billing.OnMutableInvoiceUpdateResult, error)

func (*LineEngine) OnMutableStandardLinesDeletedBySystem

func (e *LineEngine) OnMutableStandardLinesDeletedBySystem(ctx context.Context, input billing.OnMutableStandardLinesDeletedInput) error

func (*LineEngine) OnPaymentAuthorized

func (e *LineEngine) OnPaymentAuthorized(ctx context.Context, input billing.OnPaymentAuthorizedInput) error

func (*LineEngine) OnPaymentSettled

func (e *LineEngine) OnPaymentSettled(ctx context.Context, input billing.OnPaymentSettledInput) error

func (*LineEngine) OnStandardInvoiceCreated

func (e *LineEngine) OnStandardInvoiceCreated(ctx context.Context, input billing.OnStandardInvoiceCreatedInput) (billing.StandardLines, error)

func (*LineEngine) OnUnsupportedCreditNote

func (e *LineEngine) OnUnsupportedCreditNote(ctx context.Context, input billing.OnUnsupportedCreditNoteInput) error

func (*LineEngine) ValidateMutableInvoiceLineEditViaAPI

func (e *LineEngine) ValidateMutableInvoiceLineEditViaAPI(ctx context.Context, input billing.OnMutableInvoiceUpdateInput) error

type StateMachineConfig

type StateMachineConfig struct {
	Charge             usagebased.Charge
	Adapter            usagebased.Adapter
	Rater              usagebasedrating.Service
	Runs               *usagebasedrun.Service
	Logger             *slog.Logger
	CustomerOverride   billing.CustomerOverrideWithDetails
	FeatureMeter       feature.FeatureMeter
	CurrencyCalculator currencyx.Calculator
}

func (StateMachineConfig) Validate

func (c StateMachineConfig) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL