Documentation
¶
Index ¶
- func CloseConnection(tb testing.TB, sqlStore *SQLStore)
- func GetMillis() int64
- func LatestVersion() semver.Version
- type RawAccountMetadata
- type SQLStore
- func (sqlStore *SQLStore) AddParentSubnet(parentSubnet *model.ParentSubnet, subnets *[]model.Subnet) error
- func (sqlStore *SQLStore) ClaimSubnet(cidr string, accountID string) (*model.Subnet, error)
- func (sqlStore *SQLStore) CreateAccount(account *model.Account) error
- func (sqlStore *SQLStore) CreateWebhook(webhook *model.Webhook) error
- func (sqlStore *SQLStore) DeleteAccount(id string) error
- func (sqlStore *SQLStore) DeleteWebhook(id string) error
- func (sqlStore *SQLStore) GetAccount(id string) (*model.Account, error)
- func (sqlStore *SQLStore) GetAccounts(filter *model.AccountFilter) ([]*model.Account, error)
- func (sqlStore *SQLStore) GetCurrentVersion() (semver.Version, error)
- func (sqlStore *SQLStore) GetParentSubnet(id string) (model.ParentSubnet, error)
- func (sqlStore *SQLStore) GetParentSubnets(filter *model.ParentSubnetFilter) ([]model.ParentSubnet, error)
- func (sqlStore *SQLStore) GetSubnet(id string) (*model.Subnet, error)
- func (sqlStore *SQLStore) GetSubnets(filter *model.SubnetFilter) ([]*model.Subnet, error)
- func (sqlStore *SQLStore) GetUnlockedAccountsPendingWork() ([]*model.Account, error)
- func (sqlStore *SQLStore) GetWebhook(id string) (*model.Webhook, error)
- func (sqlStore *SQLStore) GetWebhooks(filter *model.WebhookFilter) ([]*model.Webhook, error)
- func (sqlStore *SQLStore) LockAccount(accountID, lockerID string) (bool, error)
- func (sqlStore *SQLStore) LockAccountAPI(accountID string) error
- func (sqlStore *SQLStore) LockParentSubnet(subnet, lockerID string) (bool, error)
- func (sqlStore *SQLStore) LockSubnet(subnet, lockerID string) (bool, error)
- func (sqlStore *SQLStore) Migrate() error
- func (sqlStore *SQLStore) SubnetCleanup(cidr string) error
- func (sqlStore *SQLStore) UnlockAccount(accountID, lockerID string, force bool) (bool, error)
- func (sqlStore *SQLStore) UnlockAccountAPI(accountID string) error
- func (sqlStore *SQLStore) UnlockParentSubnet(subnet, lockerID string, force bool) (bool, error)
- func (sqlStore *SQLStore) UnlockSubnet(subnet, lockerID string, force bool) (bool, error)
- func (sqlStore *SQLStore) UpdateAccount(account *model.Account) error
- func (sqlStore *SQLStore) UpdateSubnet(subnet *model.Subnet) error
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseConnection ¶
CloseConnection closes underlying database connection.
func GetMillis ¶
func GetMillis() int64
GetMillis is a convenience method to get milliseconds since epoch.
func LatestVersion ¶
LatestVersion returns the version to which the last migration migrates.
Types ¶
type RawAccountMetadata ¶
RawAccountMetadata is the raw byte metadata for a account.
type SQLStore ¶
type SQLStore struct {
// contains filtered or unexported fields
}
SQLStore abstracts access to the database.
func MakeTestSQLStore ¶
func MakeTestSQLStore(tb testing.TB, logger log.FieldLogger) *SQLStore
MakeTestSQLStore creates a SQLStore for use with unit tests.
func New ¶
func New(dsn string, logger logrus.FieldLogger) (*SQLStore, error)
New constructs a new instance of SQLStore.
func (*SQLStore) AddParentSubnet ¶
func (sqlStore *SQLStore) AddParentSubnet(parentSubnet *model.ParentSubnet, subnets *[]model.Subnet) error
AddParentSubnet records the given parent subnet to the database.
func (*SQLStore) ClaimSubnet ¶
ClaimSubnet claims a subnet and associates it with an account. If an empty subnet is passed a random one will be allocated.
func (*SQLStore) CreateAccount ¶
CreateAccount records the given account to the database, assigning it a unique ID.
func (*SQLStore) CreateWebhook ¶
CreateWebhook records the given webhook to the database, assigning it a unique ID.
func (*SQLStore) DeleteAccount ¶
DeleteAccount marks the given account as deleted, but does not remove the record from the database.
func (*SQLStore) DeleteWebhook ¶
DeleteWebhook marks the given webhook as deleted, but does not remove the record from the database.
func (*SQLStore) GetAccount ¶
GetAccount fetches the given account by id.
func (*SQLStore) GetAccounts ¶
GetAccounts fetches the given page of created accounts. The first page is 0.
func (*SQLStore) GetCurrentVersion ¶
GetCurrentVersion queries the System table for the current database version.
func (*SQLStore) GetParentSubnet ¶
func (sqlStore *SQLStore) GetParentSubnet(id string) (model.ParentSubnet, error)
GetParentSubnet fetches the given parent subnet by subnet range.
func (*SQLStore) GetParentSubnets ¶
func (sqlStore *SQLStore) GetParentSubnets(filter *model.ParentSubnetFilter) ([]model.ParentSubnet, error)
GetParentSubnets fetches the given page of added parent subnets. The first page is 0.
func (*SQLStore) GetSubnets ¶
GetSubnets fetches the given page of added subnets. The first page is 0.
func (*SQLStore) GetUnlockedAccountsPendingWork ¶
GetUnlockedAccountsPendingWork returns an unlocked account in a pending state.
func (*SQLStore) GetWebhook ¶
GetWebhook fetches the given webhook by id.
func (*SQLStore) GetWebhooks ¶
GetWebhooks fetches the given page of created webhooks. The first page is 0.
func (*SQLStore) LockAccount ¶
LockAccount marks the account as locked for exclusive use by the caller.
func (*SQLStore) LockAccountAPI ¶
LockAccountAPI locks updates to the account from the API.
func (*SQLStore) LockParentSubnet ¶
LockParentSubnet marks the parent subnet as locked for exclusive use by the caller.
func (*SQLStore) LockSubnet ¶
LockSubnet marks the subnet as locked for exclusive use by the caller.
func (*SQLStore) Migrate ¶
Migrate advances the schema of the configured database to the latest version.
func (*SQLStore) SubnetCleanup ¶
SubnetCleanup is cleaning up a subnet making it available for claim.
func (*SQLStore) UnlockAccount ¶
UnlockAccount releases a lock previously acquired against a caller.
func (*SQLStore) UnlockAccountAPI ¶
UnlockAccountAPI unlocks updates to the account from the API.
func (*SQLStore) UnlockParentSubnet ¶
UnlockParentSubnet releases a lock previously acquired against a caller.
func (*SQLStore) UnlockSubnet ¶
UnlockSubnet releases a lock previously acquired against a caller.
func (*SQLStore) UpdateAccount ¶
UpdateAccount updates the given account in the database.
type Transaction ¶
Transaction is a wrapper around *sqlx.Tx providing convenience methods.
func (*Transaction) Commit ¶
func (t *Transaction) Commit() error
Commit commits the pending transaction.
func (*Transaction) RollbackUnlessCommitted ¶
func (t *Transaction) RollbackUnlessCommitted()
RollbackUnlessCommitted rollback the transaction if it is not committed.