usage

package
v0.0.0-...-996fa4a Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPStorage

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

HTTPStorage represents a usage storage which posts meters over HTTP.

func NewHTTP

func NewHTTP() *HTTPStorage

NewHTTP creates a new HTTP storage

func (*HTTPStorage) Close

func (s *HTTPStorage) Close() error

Close closes the storage.

func (*HTTPStorage) Configure

func (s *HTTPStorage) Configure(config map[string]interface{}) (err error)

Configure configures the provider.

func (*HTTPStorage) Get

func (s *HTTPStorage) Get(id uint32) Meter

Get retrieves a meter for a contract.

func (*HTTPStorage) Name

func (s *HTTPStorage) Name() string

Name returns the name of the provider.

type Meter

type Meter interface {
	GetContract() uint32   // Returns the associated contract.
	AddIngress(size int64) // Records the ingress message size.
	AddEgress(size int64)  // Records the egress message size.
	AddDevice(addr string) // Records the device address.
}

Meter represents a tracker for incoming and outgoing traffic.

func NewMeter

func NewMeter(contract uint32) Meter

NewMeter constructs a new usage statistics instance.

type Metering

type Metering interface {
	config.Provider

	// Get retrieves a meter for a contract.
	Get(id uint32) Meter
}

Metering represents a contract for a usage metering

type NoopStorage

type NoopStorage struct{}

NoopStorage represents a usage storage which does nothing.

func NewNoop

func NewNoop() *NoopStorage

NewNoop creates a new no-op storage.

func (*NoopStorage) Configure

func (s *NoopStorage) Configure(config map[string]interface{}) error

Configure configures the provider

func (*NoopStorage) Get

func (s *NoopStorage) Get(id uint32) Meter

Get retrieves a meter for a contract.

func (*NoopStorage) Name

func (s *NoopStorage) Name() string

Name returns the name of the provider.

Jump to

Keyboard shortcuts

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