postgres_connector

package
v1.0.0-beta.72 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPostgresConnector

func NewPostgresConnector(
	logger *slog.Logger,
	db *db.Client,
	streamingConnector streaming.Connector,
	meterRepository meter.Repository,
) credit.Connector

func Open

func Open(databaseURL string) (*db.Client, error)

Open new connection

Types

type PostgresConnector

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

func (*PostgresConnector) CreateFeature

func (c *PostgresConnector) CreateFeature(ctx context.Context, namespace string, featureIn credit.Feature) (credit.Feature, error)

CreateFeature creates a feature.

func (*PostgresConnector) CreateGrant

func (c *PostgresConnector) CreateGrant(ctx context.Context, namespace string, grantIn credit.Grant) (credit.Grant, error)

func (*PostgresConnector) CreateLedger

func (c *PostgresConnector) CreateLedger(ctx context.Context, namespace string, ledgerIn credit.Ledger) (credit.Ledger, error)

func (*PostgresConnector) DeleteFeature

func (c *PostgresConnector) DeleteFeature(ctx context.Context, namespace string, id ulid.ULID) error

DeleteFeature deletes a feature.

func (*PostgresConnector) GetBalance

func (a *PostgresConnector) GetBalance(
	ctx context.Context,
	namespace string,
	ledgerID ulid.ULID,
	cutline time.Time,
) (credit.Balance, error)

func (*PostgresConnector) GetFeature

func (c *PostgresConnector) GetFeature(ctx context.Context, namespace string, id ulid.ULID) (credit.Feature, error)

GetFeature gets a single feature by ID.

func (*PostgresConnector) GetGrant

func (c *PostgresConnector) GetGrant(ctx context.Context, namespace string, id ulid.ULID) (credit.Grant, error)

func (*PostgresConnector) GetHighWatermark

func (c *PostgresConnector) GetHighWatermark(ctx context.Context, namespace string, ledgerID ulid.ULID) (credit.HighWatermark, error)

GetHighWatermark returns the high watermark for the given credit and subject pair.

func (*PostgresConnector) GetHistory

func (a *PostgresConnector) GetHistory(
	ctx context.Context,
	namespace string,
	ledgerID ulid.ULID,
	from time.Time,
	to time.Time,
	limit int,
) (credit.LedgerEntryList, error)

func (*PostgresConnector) ListFeatures

func (c *PostgresConnector) ListFeatures(ctx context.Context, namespace string, params credit.ListFeaturesParams) ([]credit.Feature, error)

ListFeatures lists features.

func (*PostgresConnector) ListGrants

func (c *PostgresConnector) ListGrants(ctx context.Context, namespace string, params credit.ListGrantsParams) ([]credit.Grant, error)

func (*PostgresConnector) ListLedgers

func (c *PostgresConnector) ListLedgers(ctx context.Context, namespace string, params credit.ListLedgersParams) ([]credit.Ledger, error)

func (*PostgresConnector) Reset

func (c *PostgresConnector) Reset(ctx context.Context, namespace string, reset credit.Reset) (credit.Reset, []credit.Grant, error)

Reset resets the ledger for the subject. Rolls over grants with rollover configuration.

func (*PostgresConnector) VoidGrant

func (c *PostgresConnector) VoidGrant(ctx context.Context, namespace string, grantIn credit.Grant) (credit.Grant, error)

type TransactionManager

type TransactionManager interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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