grant

package
v0.0.0-...-8a10f5f Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package grant is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPostgres

func NewPostgres() (Datastore, ReadOnlyDatastore, error)

NewPostgres creates postgres connections

Types

type ByExpiryTimestamp

type ByExpiryTimestamp []Grant

ByExpiryTimestamp implements sort.Interface for []Grant based on the ExpiryTimestamp field.

func (ByExpiryTimestamp) Len

func (a ByExpiryTimestamp) Len() int

func (ByExpiryTimestamp) Less

func (a ByExpiryTimestamp) Less(i, j int) bool

func (ByExpiryTimestamp) Swap

func (a ByExpiryTimestamp) Swap(i, j int)

type Datastore

type Datastore interface {
	datastore.Datastore
	// GetGrantsOrderedByExpiry returns ordered grant claims with optional promotion type filter
	GetGrantsOrderedByExpiry(wallet walletutils.Info, promotionType string) ([]Grant, error)
}

Datastore abstracts over the underlying datastore

func NewDB

func NewDB(databaseURL string, performMigration bool, migrationTrack string, dbStatsPrefix ...string) (Datastore, error)

NewDB creates a new Postgres Datastore

type DatastoreWithPrometheus

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

DatastoreWithPrometheus implements Datastore interface with all methods wrapped with Prometheus metrics

func NewDatastoreWithPrometheus

func NewDatastoreWithPrometheus(base Datastore, instanceName string) DatastoreWithPrometheus

NewDatastoreWithPrometheus returns an instance of the Datastore decorated with prometheus summary metric

func (DatastoreWithPrometheus) BeginTx

func (_d DatastoreWithPrometheus) BeginTx() (tp1 *sqlx.Tx, err error)

BeginTx implements Datastore

func (DatastoreWithPrometheus) GetGrantsOrderedByExpiry

func (_d DatastoreWithPrometheus) GetGrantsOrderedByExpiry(wallet walletutils.Info, promotionType string) (ga1 []Grant, err error)

GetGrantsOrderedByExpiry implements Datastore

func (DatastoreWithPrometheus) Migrate

func (_d DatastoreWithPrometheus) Migrate(p1 ...uint) (err error)

Migrate implements Datastore

func (DatastoreWithPrometheus) NewMigrate

func (_d DatastoreWithPrometheus) NewMigrate() (mp1 *migrate.Migrate, err error)

NewMigrate implements Datastore

func (DatastoreWithPrometheus) RawDB

func (_d DatastoreWithPrometheus) RawDB() (dp1 *sqlx.DB)

RawDB implements Datastore

func (DatastoreWithPrometheus) RollbackTx

func (_d DatastoreWithPrometheus) RollbackTx(tx *sqlx.Tx)

RollbackTx implements Datastore

func (DatastoreWithPrometheus) RollbackTxAndHandle

func (_d DatastoreWithPrometheus) RollbackTxAndHandle(tx *sqlx.Tx) (err error)

RollbackTxAndHandle implements Datastore

type Grant

type Grant struct {
	AltCurrency       *altcurrency.AltCurrency `json:"altcurrency" valid:"-"`
	GrantID           uuid.UUID                `json:"grantId" valid:"-" db:"id"`
	Probi             decimal.Decimal          `json:"probi" valid:"-"`
	PromotionID       uuid.UUID                `json:"promotionId" valid:"-" db:"promotion_id"`
	MaturityTimestamp int64                    `json:"maturityTime" valid:"-"`
	ExpiryTimestamp   int64                    `json:"expiryTime" valid:"-"`
	Type              string                   `json:"type,omitempty" valid:"-" db:"promotion_type"`
	ProviderID        *uuid.UUID               `json:"providerId,omitempty" valid:"-"`
}

Grant - a "check" good for the amount inscribed, redeemable between maturityTime and expiryTime

type MockDatastore

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

MockDatastore is a mock of Datastore interface.

func NewMockDatastore

func NewMockDatastore(ctrl *gomock.Controller) *MockDatastore

NewMockDatastore creates a new mock instance.

func (*MockDatastore) BeginTx

func (m *MockDatastore) BeginTx() (*sqlx.Tx, error)

BeginTx mocks base method.

func (*MockDatastore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDatastore) GetGrantsOrderedByExpiry

func (m *MockDatastore) GetGrantsOrderedByExpiry(wallet wallet.Info, promotionType string) ([]Grant, error)

GetGrantsOrderedByExpiry mocks base method.

func (*MockDatastore) Migrate

func (m *MockDatastore) Migrate(arg0 ...uint) error

Migrate mocks base method.

func (*MockDatastore) NewMigrate

func (m *MockDatastore) NewMigrate() (*v4.Migrate, error)

NewMigrate mocks base method.

func (*MockDatastore) RawDB

func (m *MockDatastore) RawDB() *sqlx.DB

RawDB mocks base method.

func (*MockDatastore) RollbackTx

func (m *MockDatastore) RollbackTx(tx *sqlx.Tx)

RollbackTx mocks base method.

func (*MockDatastore) RollbackTxAndHandle

func (m *MockDatastore) RollbackTxAndHandle(tx *sqlx.Tx) error

RollbackTxAndHandle mocks base method.

type MockDatastoreMockRecorder

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

MockDatastoreMockRecorder is the mock recorder for MockDatastore.

func (*MockDatastoreMockRecorder) BeginTx

func (mr *MockDatastoreMockRecorder) BeginTx() *gomock.Call

BeginTx indicates an expected call of BeginTx.

func (*MockDatastoreMockRecorder) GetGrantsOrderedByExpiry

func (mr *MockDatastoreMockRecorder) GetGrantsOrderedByExpiry(wallet, promotionType interface{}) *gomock.Call

GetGrantsOrderedByExpiry indicates an expected call of GetGrantsOrderedByExpiry.

func (*MockDatastoreMockRecorder) Migrate

func (mr *MockDatastoreMockRecorder) Migrate(arg0 ...interface{}) *gomock.Call

Migrate indicates an expected call of Migrate.

func (*MockDatastoreMockRecorder) NewMigrate

func (mr *MockDatastoreMockRecorder) NewMigrate() *gomock.Call

NewMigrate indicates an expected call of NewMigrate.

func (*MockDatastoreMockRecorder) RawDB

func (mr *MockDatastoreMockRecorder) RawDB() *gomock.Call

RawDB indicates an expected call of RawDB.

func (*MockDatastoreMockRecorder) RollbackTx

func (mr *MockDatastoreMockRecorder) RollbackTx(tx interface{}) *gomock.Call

RollbackTx indicates an expected call of RollbackTx.

func (*MockDatastoreMockRecorder) RollbackTxAndHandle

func (mr *MockDatastoreMockRecorder) RollbackTxAndHandle(tx interface{}) *gomock.Call

RollbackTxAndHandle indicates an expected call of RollbackTxAndHandle.

type MockReadOnlyDatastore

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

MockReadOnlyDatastore is a mock of ReadOnlyDatastore interface.

func NewMockReadOnlyDatastore

func NewMockReadOnlyDatastore(ctrl *gomock.Controller) *MockReadOnlyDatastore

NewMockReadOnlyDatastore creates a new mock instance.

func (*MockReadOnlyDatastore) BeginTx

func (m *MockReadOnlyDatastore) BeginTx() (*sqlx.Tx, error)

BeginTx mocks base method.

func (*MockReadOnlyDatastore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockReadOnlyDatastore) GetGrantsOrderedByExpiry

func (m *MockReadOnlyDatastore) GetGrantsOrderedByExpiry(wallet wallet.Info, promotionType string) ([]Grant, error)

GetGrantsOrderedByExpiry mocks base method.

func (*MockReadOnlyDatastore) Migrate

func (m *MockReadOnlyDatastore) Migrate(arg0 ...uint) error

Migrate mocks base method.

func (*MockReadOnlyDatastore) NewMigrate

func (m *MockReadOnlyDatastore) NewMigrate() (*v4.Migrate, error)

NewMigrate mocks base method.

func (*MockReadOnlyDatastore) RawDB

func (m *MockReadOnlyDatastore) RawDB() *sqlx.DB

RawDB mocks base method.

func (*MockReadOnlyDatastore) RollbackTx

func (m *MockReadOnlyDatastore) RollbackTx(tx *sqlx.Tx)

RollbackTx mocks base method.

func (*MockReadOnlyDatastore) RollbackTxAndHandle

func (m *MockReadOnlyDatastore) RollbackTxAndHandle(tx *sqlx.Tx) error

RollbackTxAndHandle mocks base method.

type MockReadOnlyDatastoreMockRecorder

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

MockReadOnlyDatastoreMockRecorder is the mock recorder for MockReadOnlyDatastore.

func (*MockReadOnlyDatastoreMockRecorder) BeginTx

BeginTx indicates an expected call of BeginTx.

func (*MockReadOnlyDatastoreMockRecorder) GetGrantsOrderedByExpiry

func (mr *MockReadOnlyDatastoreMockRecorder) GetGrantsOrderedByExpiry(wallet, promotionType interface{}) *gomock.Call

GetGrantsOrderedByExpiry indicates an expected call of GetGrantsOrderedByExpiry.

func (*MockReadOnlyDatastoreMockRecorder) Migrate

func (mr *MockReadOnlyDatastoreMockRecorder) Migrate(arg0 ...interface{}) *gomock.Call

Migrate indicates an expected call of Migrate.

func (*MockReadOnlyDatastoreMockRecorder) NewMigrate

func (mr *MockReadOnlyDatastoreMockRecorder) NewMigrate() *gomock.Call

NewMigrate indicates an expected call of NewMigrate.

func (*MockReadOnlyDatastoreMockRecorder) RawDB

RawDB indicates an expected call of RawDB.

func (*MockReadOnlyDatastoreMockRecorder) RollbackTx

func (mr *MockReadOnlyDatastoreMockRecorder) RollbackTx(tx interface{}) *gomock.Call

RollbackTx indicates an expected call of RollbackTx.

func (*MockReadOnlyDatastoreMockRecorder) RollbackTxAndHandle

func (mr *MockReadOnlyDatastoreMockRecorder) RollbackTxAndHandle(tx interface{}) *gomock.Call

RollbackTxAndHandle indicates an expected call of RollbackTxAndHandle.

type Postgres

type Postgres struct {
	datastore.Postgres
}

Postgres is a Datastore wrapper around a postgres database

func (*Postgres) GetGrantsOrderedByExpiry

func (pg *Postgres) GetGrantsOrderedByExpiry(wallet walletutils.Info, promotionType string) ([]Grant, error)

GetGrantsOrderedByExpiry returns ordered grant claims for a wallet

type ReadOnlyDatastore

type ReadOnlyDatastore interface {
	datastore.Datastore
	// GetGrantsOrderedByExpiry returns ordered grant claims with optional promotion type filter
	GetGrantsOrderedByExpiry(wallet walletutils.Info, promotionType string) ([]Grant, error)
}

ReadOnlyDatastore includes all database methods that can be made with a read only db connection

func NewRODB

func NewRODB(databaseURL string, performMigration bool, migrationTrack string, dbStatsPrefix ...string) (ReadOnlyDatastore, error)

NewRODB creates a new Postgres RO Datastore

type ReadOnlyDatastoreWithPrometheus

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

ReadOnlyDatastoreWithPrometheus implements ReadOnlyDatastore interface with all methods wrapped with Prometheus metrics

func NewReadOnlyDatastoreWithPrometheus

func NewReadOnlyDatastoreWithPrometheus(base ReadOnlyDatastore, instanceName string) ReadOnlyDatastoreWithPrometheus

NewReadOnlyDatastoreWithPrometheus returns an instance of the ReadOnlyDatastore decorated with prometheus summary metric

func (ReadOnlyDatastoreWithPrometheus) BeginTx

func (_d ReadOnlyDatastoreWithPrometheus) BeginTx() (tp1 *sqlx.Tx, err error)

BeginTx implements ReadOnlyDatastore

func (ReadOnlyDatastoreWithPrometheus) GetGrantsOrderedByExpiry

func (_d ReadOnlyDatastoreWithPrometheus) GetGrantsOrderedByExpiry(wallet walletutils.Info, promotionType string) (ga1 []Grant, err error)

GetGrantsOrderedByExpiry implements ReadOnlyDatastore

func (ReadOnlyDatastoreWithPrometheus) Migrate

func (_d ReadOnlyDatastoreWithPrometheus) Migrate(p1 ...uint) (err error)

Migrate implements ReadOnlyDatastore

func (ReadOnlyDatastoreWithPrometheus) NewMigrate

func (_d ReadOnlyDatastoreWithPrometheus) NewMigrate() (mp1 *migrate.Migrate, err error)

NewMigrate implements ReadOnlyDatastore

func (ReadOnlyDatastoreWithPrometheus) RawDB

func (_d ReadOnlyDatastoreWithPrometheus) RawDB() (dp1 *sqlx.DB)

RawDB implements ReadOnlyDatastore

func (ReadOnlyDatastoreWithPrometheus) RollbackTx

func (_d ReadOnlyDatastoreWithPrometheus) RollbackTx(tx *sqlx.Tx)

RollbackTx implements ReadOnlyDatastore

func (ReadOnlyDatastoreWithPrometheus) RollbackTxAndHandle

func (_d ReadOnlyDatastoreWithPrometheus) RollbackTxAndHandle(tx *sqlx.Tx) (err error)

RollbackTxAndHandle implements ReadOnlyDatastore

type Service

type Service struct {
	Datastore   Datastore
	RoDatastore ReadOnlyDatastore
	// contains filtered or unexported fields
}

Service contains datastore

func InitService

func InitService(
	ctx context.Context,
	datastore Datastore,
	roDatastore ReadOnlyDatastore,
	walletService *wallet.Service,
	promotionService *promotion.Service,
) (*Service, error)

InitService initializes the grant service

func (*Service) GetGrantsOrderedByExpiry

func (service *Service) GetGrantsOrderedByExpiry(wallet wallet.Info, promotionType string) ([]Grant, error)

GetGrantsOrderedByExpiry returns ordered grant claims for a wallet with optional promotionType filter

func (*Service) Jobs

func (s *Service) Jobs() []srv.Job

Jobs - Implement srv.JobService interface

func (*Service) ReadableDatastore

func (s *Service) ReadableDatastore() ReadOnlyDatastore

ReadableDatastore returns a read only datastore if available, otherwise a normal datastore

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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