grant

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: MPL-2.0 Imports: 26 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 added in v0.1.2

func NewPostgres() (Datastore, ReadOnlyDatastore, error)

NewPostgres creates postgres connections

Types

type ByExpiryTimestamp added in v0.1.1

type ByExpiryTimestamp []Grant

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

func (ByExpiryTimestamp) Len added in v0.1.1

func (a ByExpiryTimestamp) Len() int

func (ByExpiryTimestamp) Less added in v0.1.1

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

func (ByExpiryTimestamp) Swap added in v0.1.1

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

type Datastore added in v0.1.2

type Datastore interface {
	grantserver.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 added in v0.4.0

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

NewDB creates a new Postgres Datastore

type DatastoreWithPrometheus added in v0.3.0

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

DatastoreWithPrometheus implements Datastore interface with all methods wrapped with Prometheus metrics

func NewDatastoreWithPrometheus added in v0.3.0

func NewDatastoreWithPrometheus(base Datastore, instanceName string) DatastoreWithPrometheus

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

func (DatastoreWithPrometheus) GetGrantsOrderedByExpiry added in v0.3.0

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

GetGrantsOrderedByExpiry implements Datastore

func (DatastoreWithPrometheus) Migrate added in v0.3.0

func (_d DatastoreWithPrometheus) Migrate() (err error)

Migrate implements Datastore

func (DatastoreWithPrometheus) NewMigrate added in v0.3.0

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

NewMigrate implements Datastore

func (DatastoreWithPrometheus) RawDB added in v0.3.0

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

RawDB implements Datastore

func (DatastoreWithPrometheus) RollbackTx added in v0.3.0

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

RollbackTx implements Datastore

func (DatastoreWithPrometheus) RollbackTxAndHandle added in v0.4.0

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 added in v0.2.0

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

MockDatastore is a mock of Datastore interface

func NewMockDatastore added in v0.2.0

func NewMockDatastore(ctrl *gomock.Controller) *MockDatastore

NewMockDatastore creates a new mock instance

func (*MockDatastore) EXPECT added in v0.2.0

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

func (*MockDatastore) GetGrantsOrderedByExpiry added in v0.2.0

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

GetGrantsOrderedByExpiry mocks base method

func (*MockDatastore) Migrate added in v0.3.0

func (m *MockDatastore) Migrate() error

Migrate mocks base method

func (*MockDatastore) NewMigrate added in v0.3.0

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

NewMigrate mocks base method

func (*MockDatastore) RawDB added in v0.3.0

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

RawDB mocks base method

func (*MockDatastore) RollbackTx added in v0.3.0

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

RollbackTx mocks base method

func (*MockDatastore) RollbackTxAndHandle added in v0.4.0

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

RollbackTxAndHandle mocks base method

type MockDatastoreMockRecorder added in v0.2.0

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

MockDatastoreMockRecorder is the mock recorder for MockDatastore

func (*MockDatastoreMockRecorder) GetGrantsOrderedByExpiry added in v0.2.0

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

GetGrantsOrderedByExpiry indicates an expected call of GetGrantsOrderedByExpiry

func (*MockDatastoreMockRecorder) Migrate added in v0.3.0

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

Migrate indicates an expected call of Migrate

func (*MockDatastoreMockRecorder) NewMigrate added in v0.3.0

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

NewMigrate indicates an expected call of NewMigrate

func (*MockDatastoreMockRecorder) RawDB added in v0.3.0

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

RawDB indicates an expected call of RawDB

func (*MockDatastoreMockRecorder) RollbackTx added in v0.3.0

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

RollbackTx indicates an expected call of RollbackTx

func (*MockDatastoreMockRecorder) RollbackTxAndHandle added in v0.4.0

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

RollbackTxAndHandle indicates an expected call of RollbackTxAndHandle

type MockReadOnlyDatastore added in v0.4.0

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

MockReadOnlyDatastore is a mock of ReadOnlyDatastore interface

func NewMockReadOnlyDatastore added in v0.4.0

func NewMockReadOnlyDatastore(ctrl *gomock.Controller) *MockReadOnlyDatastore

NewMockReadOnlyDatastore creates a new mock instance

func (*MockReadOnlyDatastore) EXPECT added in v0.4.0

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

func (*MockReadOnlyDatastore) GetGrantsOrderedByExpiry added in v0.4.0

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

GetGrantsOrderedByExpiry mocks base method

func (*MockReadOnlyDatastore) Migrate added in v0.4.0

func (m *MockReadOnlyDatastore) Migrate() error

Migrate mocks base method

func (*MockReadOnlyDatastore) NewMigrate added in v0.4.0

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

NewMigrate mocks base method

func (*MockReadOnlyDatastore) RawDB added in v0.4.0

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

RawDB mocks base method

func (*MockReadOnlyDatastore) RollbackTx added in v0.4.0

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

RollbackTx mocks base method

func (*MockReadOnlyDatastore) RollbackTxAndHandle added in v0.4.0

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

RollbackTxAndHandle mocks base method

type MockReadOnlyDatastoreMockRecorder added in v0.4.0

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

MockReadOnlyDatastoreMockRecorder is the mock recorder for MockReadOnlyDatastore

func (*MockReadOnlyDatastoreMockRecorder) GetGrantsOrderedByExpiry added in v0.4.0

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

GetGrantsOrderedByExpiry indicates an expected call of GetGrantsOrderedByExpiry

func (*MockReadOnlyDatastoreMockRecorder) Migrate added in v0.4.0

Migrate indicates an expected call of Migrate

func (*MockReadOnlyDatastoreMockRecorder) NewMigrate added in v0.4.0

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

NewMigrate indicates an expected call of NewMigrate

func (*MockReadOnlyDatastoreMockRecorder) RawDB added in v0.4.0

RawDB indicates an expected call of RawDB

func (*MockReadOnlyDatastoreMockRecorder) RollbackTx added in v0.4.0

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

RollbackTx indicates an expected call of RollbackTx

func (*MockReadOnlyDatastoreMockRecorder) RollbackTxAndHandle added in v0.4.0

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

RollbackTxAndHandle indicates an expected call of RollbackTxAndHandle

type Postgres added in v0.1.2

type Postgres struct {
	grantserver.Postgres
}

Postgres is a Datastore wrapper around a postgres database

func (*Postgres) GetGrantsOrderedByExpiry added in v0.2.0

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

GetGrantsOrderedByExpiry returns ordered grant claims for a wallet

type ReadOnlyDatastore added in v0.2.0

type ReadOnlyDatastore interface {
	grantserver.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 added in v0.4.0

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

NewRODB creates a new Postgres RO Datastore

type ReadOnlyDatastoreWithPrometheus added in v0.3.0

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

ReadOnlyDatastoreWithPrometheus implements ReadOnlyDatastore interface with all methods wrapped with Prometheus metrics

func NewReadOnlyDatastoreWithPrometheus added in v0.3.0

func NewReadOnlyDatastoreWithPrometheus(base ReadOnlyDatastore, instanceName string) ReadOnlyDatastoreWithPrometheus

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

func (ReadOnlyDatastoreWithPrometheus) GetGrantsOrderedByExpiry added in v0.3.0

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

GetGrantsOrderedByExpiry implements ReadOnlyDatastore

func (ReadOnlyDatastoreWithPrometheus) Migrate added in v0.3.0

func (_d ReadOnlyDatastoreWithPrometheus) Migrate() (err error)

Migrate implements ReadOnlyDatastore

func (ReadOnlyDatastoreWithPrometheus) NewMigrate added in v0.3.0

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

NewMigrate implements ReadOnlyDatastore

func (ReadOnlyDatastoreWithPrometheus) RawDB added in v0.3.0

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

RawDB implements ReadOnlyDatastore

func (ReadOnlyDatastoreWithPrometheus) RollbackTx added in v0.3.0

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

RollbackTx implements ReadOnlyDatastore

func (ReadOnlyDatastoreWithPrometheus) RollbackTxAndHandle added in v0.4.0

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

RollbackTxAndHandle implements ReadOnlyDatastore

type Service added in v0.1.2

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

Service contains datastore as well as prometheus metrics

func InitService added in v0.1.2

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

InitService initializes the grant service

func (*Service) Collect added in v0.1.2

func (s *Service) Collect(ch chan<- prometheus.Metric)

Collect returns the current state of all metrics of the collector. We implement this and the Describe function to fulfill the prometheus.Collector interface

func (*Service) Describe added in v0.1.2

func (s *Service) Describe(ch chan<- *prometheus.Desc)

Describe returns all descriptions of the collector. We implement this and the Collect function to fulfill the prometheus.Collector interface

func (*Service) GetGrantsOrderedByExpiry added in v0.2.0

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 added in v0.3.0

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

Jobs - Implement srv.JobService interface

func (*Service) ReadableDatastore added in v0.2.0

func (s *Service) ReadableDatastore() ReadOnlyDatastore

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

Jump to

Keyboard shortcuts

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