balanceworker

package
v1.0.0-beta.182 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultIncludeDeletedDuration is the default duration for which deleted entitlements are included in recalculation.
	// This ensures that the recent deleted snapshot events are also resent.
	DefaultIncludeDeletedDuration = 24 * time.Hour
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BalanceWorkerRepository

type BalanceWorkerRepository interface {
	ListAffectedEntitlements(ctx context.Context, filterPairs []IngestEventQueryFilter) ([]IngestEventDataResponse, error)
}

type IngestEventDataResponse

type IngestEventDataResponse struct {
	Namespace     string
	EntitlementID string
	SubjectKey    string
	// not all entitlements have a meter associated
	MeterSlug *string
}

type IngestEventQueryFilter

type IngestEventQueryFilter struct {
	Namespace  string
	SubjectKey string
	MeterSlugs []string
}

type NamespacedID

type NamespacedID = pkgmodels.NamespacedID

type Recalculator

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

func NewRecalculator

func NewRecalculator(opts RecalculatorOptions) (*Recalculator, error)

func (*Recalculator) Recalculate

func (r *Recalculator) Recalculate(ctx context.Context, ns string) error

type RecalculatorOptions

type RecalculatorOptions struct {
	Entitlement     *registry.Entitlement
	SubjectResolver SubjectResolver
	EventBus        eventbus.Publisher
	MetricMeter     metric.Meter
}

func (RecalculatorOptions) Validate

func (o RecalculatorOptions) Validate() error

type SubjectResolver

type SubjectResolver interface {
	GetSubjectByKey(ctx context.Context, namespace, key string) (models.Subject, error)
}

type Worker

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

func New

func New(opts WorkerOptions) (*Worker, error)

func (*Worker) Close

func (w *Worker) Close() error

func (*Worker) GetEntitlementsAffectedByMeterSubject

func (w *Worker) GetEntitlementsAffectedByMeterSubject(ctx context.Context, namespace string, meterSlugs []string, subject string) ([]NamespacedID, error)

func (*Worker) Run

func (w *Worker) Run(ctx context.Context) error

type WorkerOptions

type WorkerOptions struct {
	SystemEventsTopic string
	IngestEventsTopic string

	Router   router.Options
	EventBus eventbus.Publisher

	Entitlement *registry.Entitlement
	Repo        BalanceWorkerRepository
	// External connectors
	SubjectResolver SubjectResolver

	Logger *slog.Logger
}

Jump to

Keyboard shortcuts

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