Documentation
¶
Index ¶
- Constants
- Variables
- type Persistable
- type PostgresDBService
- func (p *PostgresDBService) CheckIPRecords(ip string) (exists bool, expired bool, err error)
- func (p *PostgresDBService) Finish()
- func (db *PostgresDBService) GetArchDistribution() (map[string]interface{}, error)
- func (db *PostgresDBService) GetClientDistribution() (map[string]interface{}, error)
- func (db *PostgresDBService) GetDeprecatedNodes() (int, error)
- func (p *PostgresDBService) GetExpiredIPInfo() ([]string, error)
- func (db *PostgresDBService) GetGeoDistribution() (map[string]interface{}, error)
- func (db *PostgresDBService) GetHostingDistribution() (map[string]interface{}, error)
- func (db *PostgresDBService) GetIPDistribution() (map[string]interface{}, error)
- func (p *PostgresDBService) GetIPInfo(ip string) (models.IPInfo, error)
- func (d *PostgresDBService) GetNonDeprecatedNodes(networkID uint64) ([]models.HostInfo, error)
- func (db *PostgresDBService) GetOsDistribution() (map[string]interface{}, error)
- func (db *PostgresDBService) GetRTTDistribution() (map[string]interface{}, error)
- func (db *PostgresDBService) GetVersionDistribution() (map[string]interface{}, error)
- func (DB *PostgresDBService) PersistActivePeers() error
- func (d *PostgresDBService) PersistENR(enr *models.ENR)
- func (p *PostgresDBService) PersistIPInfo(ip models.IPInfo)
- func (d *PostgresDBService) PersistNodeInfo(attempt models.ConnectionAttempt, nInfo models.NodeInfo, sameNetwork bool)
- func (p *PostgresDBService) UpsertIpInfo(IPInfo models.IPInfo) (query string, args []interface{})
- type QueryBatch
Constants ¶
const (
LastActivityValidRange = 180
)
const ( // RoutineFlushTimeout is the time to wait for the routine to flush the queue RoutineFlushTimeout = time.Duration(1 * time.Second) )
Variables ¶
var ( QueryTimeout = 5 * time.Minute MaxRetries = 1 ErrorNoConnFree = "no connection adquirable" )
var ( // wlogrus associated with the postgres db PsqlType = "postgres-db" MAX_BATCH_QUEUE = 1000 MAX_EPOCH_BATCH_QUEUE = 1 )
Static postgres queries, for each modification in the tables, the table needs to be reseted
Functions ¶
This section is empty.
Types ¶
type Persistable ¶
type Persistable struct {
// contains filtered or unexported fields
}
persistable is the main structure fed to the batcher allows to link batching errors with the query and values that generated it
func NewPersistable ¶
func NewPersistable() Persistable
type PostgresDBService ¶
type PostgresDBService struct {
// contains filtered or unexported fields
}
func ConnectToDB ¶
func ConnectToDB( ctx context.Context, url string, workerNum int, snapshotInterval time.Duration, ) (*PostgresDBService, error)
Connect to the PostgreSQL Database and get the multithread-proof connection from the given url-composed credentials
func (*PostgresDBService) CheckIPRecords ¶
func (p *PostgresDBService) CheckIPRecords(ip string) (exists bool, expired bool, err error)
CheckIPRecords checks if a given IP is already stored in the DB as whether its TTL has expired
func (*PostgresDBService) Finish ¶
func (p *PostgresDBService) Finish()
func (*PostgresDBService) GetArchDistribution ¶
func (db *PostgresDBService) GetArchDistribution() (map[string]interface{}, error)
func (*PostgresDBService) GetClientDistribution ¶
func (db *PostgresDBService) GetClientDistribution() (map[string]interface{}, error)
func (*PostgresDBService) GetDeprecatedNodes ¶
func (db *PostgresDBService) GetDeprecatedNodes() (int, error)
func (*PostgresDBService) GetExpiredIPInfo ¶
func (p *PostgresDBService) GetExpiredIPInfo() ([]string, error)
GetExpiredIpInfo returns all the IP whos' TTL has already expired
func (*PostgresDBService) GetGeoDistribution ¶
func (db *PostgresDBService) GetGeoDistribution() (map[string]interface{}, error)
Basic call over the whole list of non-deprecated peers
func (*PostgresDBService) GetHostingDistribution ¶
func (db *PostgresDBService) GetHostingDistribution() (map[string]interface{}, error)
func (*PostgresDBService) GetIPDistribution ¶
func (db *PostgresDBService) GetIPDistribution() (map[string]interface{}, error)
func (*PostgresDBService) GetIPInfo ¶
func (p *PostgresDBService) GetIPInfo(ip string) (models.IPInfo, error)
GetIPInfo reads all the information available for that specific IP in the DB
func (*PostgresDBService) GetNonDeprecatedNodes ¶
func (d *PostgresDBService) GetNonDeprecatedNodes(networkID uint64) ([]models.HostInfo, error)
func (*PostgresDBService) GetOsDistribution ¶
func (db *PostgresDBService) GetOsDistribution() (map[string]interface{}, error)
func (*PostgresDBService) GetRTTDistribution ¶
func (db *PostgresDBService) GetRTTDistribution() (map[string]interface{}, error)
func (*PostgresDBService) GetVersionDistribution ¶
func (db *PostgresDBService) GetVersionDistribution() (map[string]interface{}, error)
Basic call over the whole list of non-deprecated peers
func (*PostgresDBService) PersistActivePeers ¶
func (DB *PostgresDBService) PersistActivePeers() error
func (*PostgresDBService) PersistENR ¶
func (d *PostgresDBService) PersistENR(enr *models.ENR)
PersistENR queues a new ENR into the databas-e
func (*PostgresDBService) PersistIPInfo ¶
func (p *PostgresDBService) PersistIPInfo(ip models.IPInfo)
func (*PostgresDBService) PersistNodeInfo ¶
func (d *PostgresDBService) PersistNodeInfo(attempt models.ConnectionAttempt, nInfo models.NodeInfo, sameNetwork bool)
PersistNodeInfo is the main method to persist the node info into the DB
func (*PostgresDBService) UpsertIpInfo ¶
func (p *PostgresDBService) UpsertIpInfo(IPInfo models.IPInfo) (query string, args []interface{})
UpsertIP attemtps to insert IP in the DB - or Updates the data info if they where already there
type QueryBatch ¶
type QueryBatch struct {
// contains filtered or unexported fields
}
func NewQueryBatch ¶
func (*QueryBatch) AddQuery ¶
func (q *QueryBatch) AddQuery(persis Persistable)
func (*QueryBatch) IsReadyToPersist ¶
func (q *QueryBatch) IsReadyToPersist() bool
func (*QueryBatch) Len ¶
func (q *QueryBatch) Len() int
func (*QueryBatch) PersistBatch ¶
func (q *QueryBatch) PersistBatch() error