usage

package
v0.8.30 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreditService

type CreditService interface {
	Deduct(ctx context.Context, u Usage) error
}

type Service

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

func NewService

func NewService(transactionService CreditService) *Service

func (Service) Report

func (s Service) Report(ctx context.Context, usages []Usage) error

type Type

type Type string
const (
	TypeCredit  Type = "credit"
	TypeFeature Type = "feature"
)

type Usage

type Usage struct {
	ID          string
	CustomerID  string
	Source      string
	Description string

	// Type is the type of usage, it can be credit or feature
	// if credit, the amount is the amount of credits that were consumed
	// if feature, the amount is the amount of features that were used
	Type   Type
	Amount int64

	CreatedAt time.Time
	Metadata  metadata.Metadata
}

Jump to

Keyboard shortcuts

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