Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDBConnection ¶ added in v1.2.0
func NewDBConnection(options PostgresOptions) (*sql.DB, func() error, error)
DO NOT use as a direct path to the database
use NewPostgresClientFromDBInstance right after
func WriteAppUsage ¶
func WriteAppUsage(ctx context.Context, tx *sql.Tx, counts map[types.PortalAppPublicKey]api.RelayCounts) error
func WriteOriginUsage ¶
func WriteOriginUsage(ctx context.Context, tx *sql.Tx, counts map[types.PortalAppOrigin]api.RelayCounts) error
Types ¶
type PostgresClient ¶
func NewPostgresClientFromDBInstance ¶ added in v0.0.48
func NewPostgresClientFromDBInstance(db *sql.DB) PostgresClient
type PostgresOptions ¶
type Reporter ¶
type Reporter interface { // DailyUsage returns saved daily metrics for the specified time period, with each day being an entry in the results map DailyUsage(from time.Time, to time.Time) (map[time.Time]map[types.PortalAppPublicKey]api.RelayCounts, error) // TodaysUsage returns the metrics for today so far TodaysUsage() (map[types.PortalAppPublicKey]api.RelayCounts, error) TodaysOriginUsage() (map[types.PortalAppOrigin]api.RelayCounts, error) TodaysLatency() (map[types.PortalAppPublicKey][]api.Latency, error) }
Will be implemented by Postgres DB interface
type Writer ¶
type Writer interface { // TODO: rollover of entries WriteDailyUsage(counts map[time.Time]map[types.PortalAppPublicKey]api.RelayCounts, countsOrigin map[types.PortalAppOrigin]api.RelayCounts) error // WriteTodaysUsage writes todays relay counts to the underlying storage. WriteTodaysUsage(ctx context.Context, tx *sql.Tx, counts map[types.PortalAppPublicKey]api.RelayCounts, countsOrigin map[types.PortalAppOrigin]api.RelayCounts) error WriteTodaysMetrics(counts map[types.PortalAppPublicKey]api.RelayCounts, countsOrigin map[types.PortalAppOrigin]api.RelayCounts, latencies map[types.PortalAppPublicKey][]api.Latency) error // Returns oldest and most recent timestamps for stored metrics ExistingMetricsTimespan() (time.Time, time.Time, error) }
Will be implemented by Postgres DB interface
Click to show internal directories.
Click to hide internal directories.