store

package
Version: v0.0.0-...-c8a5385 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package store encapsulates all database interaction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgoricSubscription

type AgoricSubscription struct {
	gorm.Model
	SubscriptionId uint
}

type BSNIritaSubscription

type BSNIritaSubscription struct {
	gorm.Model
	SubscriptionId uint
	Addresses      SQLStringArray
	ServiceName    string
}

type BinanceSmartChainSubscription

type BinanceSmartChainSubscription struct {
	gorm.Model
	SubscriptionId uint
	Addresses      SQLStringArray
}

type CfxSubscription

type CfxSubscription struct {
	gorm.Model
	SubscriptionId uint
	Addresses      SQLStringArray
	Topics         SQLStringArray
}

type Client

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

Client holds a connection to the database.

func ConnectToDb

func ConnectToDb(uri string) (*Client, error)

ConnectToDB attempts to connect to the database URI provided, and returns a new Client instance if successful.

func (Client) Close

func (client Client) Close() error

Close will close the connection to the database.

func (Client) DeleteAllEndpointsExcept

func (client Client) DeleteAllEndpointsExcept(names []string) error

DeleteAllEndpointsExcept will call DeleteEndpoint on all endpoints not provided.

func (Client) DeleteEndpoint

func (client Client) DeleteEndpoint(name string) error

DeleteEndpoint will soft-delete any endpoint record with the name provided, as well as any Subscriptions using this endpoint.

func (Client) DeleteSubscription

func (client Client) DeleteSubscription(sub *Subscription) error

DeleteSubscription will soft-delete the subscription provided.

func (Client) LoadEndpoint

func (client Client) LoadEndpoint(name string) (Endpoint, error)

LoadEndpoint will return the endpoint in the database with the name provided.

func (Client) LoadSubscription

func (client Client) LoadSubscription(jobid string) (*Subscription, error)

func (Client) LoadSubscriptions

func (client Client) LoadSubscriptions() ([]Subscription, error)

LoadSubscriptions will find all subscriptions in the database, along with their associated endpoint and blockchain configuration, and return them in a slice.

func (Client) RestoreEndpoint

func (client Client) RestoreEndpoint(name string) error

RestoreEndpoint will restore any soft-deleted endpoint with the name provided.

func (Client) SaveEndpoint

func (client Client) SaveEndpoint(endpoint *Endpoint) error

SaveEndpoint will store the endpoint in the database and overwrite any previous record with the same name.

func (Client) SaveSubscription

func (client Client) SaveSubscription(sub *Subscription) error

SaveSubscription will validate that the Endpoint exists, then store the Subscription in the database.

type Endpoint

type Endpoint struct {
	gorm.Model
	Url        string `json:"url"`
	Type       string `json:"type"`
	RefreshInt int    `json:"refreshInterval"`
	Name       string `json:"name"`
}

type EthSubscription

type EthSubscription struct {
	gorm.Model
	SubscriptionId uint
	Addresses      SQLStringArray
	Topics         SQLStringArray
}

type KeeperSubscription

type KeeperSubscription struct {
	gorm.Model
	SubscriptionId uint
	Address        string
	UpkeepID       string
	From           common.Address
}

type NEARSubscription

type NEARSubscription struct {
	gorm.Model
	SubscriptionId uint
	AccountIds     SQLStringArray
}

type OntSubscription

type OntSubscription struct {
	gorm.Model
	SubscriptionId uint
	Addresses      SQLStringArray
}

type RuntimeConfig

type RuntimeConfig struct {
	KeeperBlockCooldown int64
}

type SQLBytes

type SQLBytes []byte

SQLBytes is a byte slice stored in the database as a string.

func (*SQLBytes) Scan

func (bytes *SQLBytes) Scan(src interface{}) error

Scan implements the sql Scanner interface.

func (SQLBytes) Value

func (bytes SQLBytes) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type SQLStringArray

type SQLStringArray []string

SQLStringArray is a string array stored in the database as comma separated values.

func (*SQLStringArray) Scan

func (arr *SQLStringArray) Scan(src interface{}) error

Scan implements the sql Scanner interface.

func (SQLStringArray) Value

func (arr SQLStringArray) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Subscription

type Subscription struct {
	gorm.Model
	ReferenceId       string
	Job               string
	EndpointName      string
	Endpoint          Endpoint `gorm:"-"`
	Ethereum          EthSubscription
	Tezos             TezosSubscription
	Substrate         SubstrateSubscription
	Ontology          OntSubscription
	BinanceSmartChain BinanceSmartChainSubscription
	NEAR              NEARSubscription
	Conflux           CfxSubscription
	Keeper            KeeperSubscription
	BSNIrita          BSNIritaSubscription
	Agoric            AgoricSubscription
}

type SubstrateSubscription

type SubstrateSubscription struct {
	gorm.Model
	SubscriptionId uint
	AccountIds     SQLStringArray
}

type TezosSubscription

type TezosSubscription struct {
	gorm.Model
	SubscriptionId uint
	Addresses      SQLStringArray
}

Jump to

Keyboard shortcuts

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