billing

package
v1.0.0-beta.122 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeUsage   string = "usage"
	EventTypeStorage string = "storage"
	TimeFormat              = time.RFC3339

	StorageIndexBytes = "index_bytes"
	StorageDbBytes    = "database_bytes"

	UsageSearchUnits = "search_units"
	UsageDbUnits     = "database_units"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountId

type AccountId = uuid.UUID

type Metronome

type Metronome struct {
	Config config.Metronome
	// contains filtered or unexported fields
}

func NewMetronomeProvider

func NewMetronomeProvider(conf config.Metronome) (*Metronome, error)

func (*Metronome) AddDefaultPlan

func (m *Metronome) AddDefaultPlan(ctx context.Context, accountId AccountId) (bool, error)

func (*Metronome) AddPlan

func (m *Metronome) AddPlan(ctx context.Context, accountId AccountId, planId uuid.UUID) (bool, error)

func (*Metronome) CreateAccount

func (m *Metronome) CreateAccount(ctx context.Context, namespaceId string, name string) (AccountId, error)

func (*Metronome) GetAccountId

func (m *Metronome) GetAccountId(ctx context.Context, namespaceId string) (AccountId, error)

func (*Metronome) GetInvoiceById

func (m *Metronome) GetInvoiceById(ctx context.Context, accountId AccountId, invoiceId string) (*api.ListInvoicesResponse, error)

func (*Metronome) GetInvoices

func (m *Metronome) GetInvoices(ctx context.Context, accountId AccountId, r *api.ListInvoicesRequest) (*api.ListInvoicesResponse, error)

func (*Metronome) GetUsage

func (*Metronome) PushStorageEvents

func (m *Metronome) PushStorageEvents(ctx context.Context, events []*StorageEvent) error

func (*Metronome) PushUsageEvents

func (m *Metronome) PushUsageEvents(ctx context.Context, events []*UsageEvent) error

type MetronomeError

type MetronomeError struct {
	HttpCode int
	Message  string
}

func NewMetronomeError

func NewMetronomeError(code int, message []byte) *MetronomeError

func (*MetronomeError) Error

func (e *MetronomeError) Error() string

type Provider

type Provider interface {
	CreateAccount(ctx context.Context, namespaceId string, name string) (AccountId, error)
	AddDefaultPlan(ctx context.Context, accountId AccountId) (bool, error)
	AddPlan(ctx context.Context, accountId AccountId, planId uuid.UUID) (bool, error)
	PushUsageEvents(ctx context.Context, events []*UsageEvent) error
	PushStorageEvents(ctx context.Context, events []*StorageEvent) error
	GetInvoices(ctx context.Context, accountId AccountId, r *api.ListInvoicesRequest) (*api.ListInvoicesResponse, error)
	GetInvoiceById(ctx context.Context, accountId AccountId, invoiceId string) (*api.ListInvoicesResponse, error)
	GetUsage(ctx context.Context, id AccountId, r *UsageRequest) (*api.GetUsageResponse, error)
	GetAccountId(ctx context.Context, namespaceId string) (AccountId, error)
}

func NewProvider

func NewProvider() Provider

type StorageEvent

type StorageEvent struct {
	biller.Event
}

type StorageEventBuilder

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

func NewStorageEventBuilder

func NewStorageEventBuilder() *StorageEventBuilder

func (*StorageEventBuilder) Build

func (sb *StorageEventBuilder) Build() *StorageEvent

func (*StorageEventBuilder) WithDatabaseBytes

func (sb *StorageEventBuilder) WithDatabaseBytes(value int64) *StorageEventBuilder

func (*StorageEventBuilder) WithIndexBytes

func (sb *StorageEventBuilder) WithIndexBytes(value int64) *StorageEventBuilder

func (*StorageEventBuilder) WithNamespaceId

func (sb *StorageEventBuilder) WithNamespaceId(id string) *StorageEventBuilder

func (*StorageEventBuilder) WithTimestamp

func (sb *StorageEventBuilder) WithTimestamp(ts time.Time) *StorageEventBuilder

func (*StorageEventBuilder) WithTransactionId

func (sb *StorageEventBuilder) WithTransactionId(id string) *StorageEventBuilder

type UsageEvent

type UsageEvent struct {
	biller.Event
}

type UsageEventBuilder

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

func NewUsageEventBuilder

func NewUsageEventBuilder() *UsageEventBuilder

func (*UsageEventBuilder) Build

func (ub *UsageEventBuilder) Build() *UsageEvent

func (*UsageEventBuilder) WithDatabaseUnits

func (ub *UsageEventBuilder) WithDatabaseUnits(value int64) *UsageEventBuilder

func (*UsageEventBuilder) WithNamespaceId

func (ub *UsageEventBuilder) WithNamespaceId(id string) *UsageEventBuilder

func (*UsageEventBuilder) WithSearchUnits

func (ub *UsageEventBuilder) WithSearchUnits(value int64) *UsageEventBuilder

func (*UsageEventBuilder) WithTimestamp

func (ub *UsageEventBuilder) WithTimestamp(ts time.Time) *UsageEventBuilder

func (*UsageEventBuilder) WithTransactionId

func (ub *UsageEventBuilder) WithTransactionId(id string) *UsageEventBuilder

type UsageReporter

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

func (*UsageReporter) Start

func (r *UsageReporter) Start()

type UsageRequest

type UsageRequest struct {
	BillableMetric *[]string
	StartTime      *time.Time
	EndTime        *time.Time
	NextPage       *string
	AggWindow      WindowSize
}

type WindowSize

type WindowSize int
const (
	Hour WindowSize = iota
	Day
)

func (WindowSize) String

func (w WindowSize) String() string

Jump to

Keyboard shortcuts

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