ntpdb

package
v0.0.0-...-29c3169 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenDB

func OpenDB(config DBConfig) (*sql.DB, error)

Types

type CreateConnectorFunc

type CreateConnectorFunc func() (driver.Connector, error)

type DBConfig

type DBConfig struct {
	DSN  string `default:"" flag:"dsn" usage:"Database DSN"`
	User string `default:"" flag:"user"`
	Pass string `default:"" flag:"pass"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Driver

type Driver struct {
	CreateConnectorFunc CreateConnectorFunc
}

func (Driver) Connect

func (d Driver) Connect(ctx context.Context) (driver.Conn, error)

func (Driver) Driver

func (d Driver) Driver() driver.Driver

func (Driver) Open

func (d Driver) Open(name string) (driver.Conn, error)

type GetMonitorPriorityRow

type GetMonitorPriorityRow struct {
	ID              uint32                 `json:"id"`
	TlsName         sql.NullString         `json:"tls_name"`
	AvgRtt          interface{}            `json:"avg_rtt"`
	MonitorPriority float64                `json:"monitor_priority"`
	AvgStep         interface{}            `json:"avg_step"`
	Healthy         interface{}            `json:"healthy"`
	MonitorStatus   MonitorsStatus         `json:"monitor_status"`
	Status          NullServerScoresStatus `json:"status"`
	Count           int64                  `json:"count"`
}

type GetScorerLogScoresParams

type GetScorerLogScoresParams struct {
	LogScoreID uint64 `json:"log_score_id"`
	Limit      int32  `json:"limit"`
}

type GetScorerRecentScoresParams

type GetScorerRecentScoresParams struct {
	ServerID       uint32             `json:"server_id"`
	MonitorStatus  ServerScoresStatus `json:"monitor_status"`
	MonitorStatus2 ServerScoresStatus `json:"monitor_status_2"`
	Ts             time.Time          `json:"ts"`
	TimeLookback   interface{}        `json:"time_lookback"`
}

type GetScorerStatusRow

type GetScorerStatusRow struct {
	ID         uint32    `json:"id"`
	ScorerID   uint32    `json:"scorer_id"`
	LogScoreID uint64    `json:"log_score_id"`
	ModifiedOn time.Time `json:"modified_on"`
	Name       string    `json:"name"`
}

type GetScorersRow

type GetScorersRow struct {
	ID         uint32         `json:"id"`
	StatusID   uint32         `json:"status_id"`
	Status     MonitorsStatus `json:"status"`
	LogScoreID uint64         `json:"log_score_id"`
	Name       string         `json:"name"`
}

type GetServerScoreParams

type GetServerScoreParams struct {
	ServerID  uint32 `json:"server_id"`
	MonitorID uint32 `json:"monitor_id"`
}

type GetServersParams

type GetServersParams struct {
	MonitorID              uint32           `json:"monitor_id"`
	IpVersion              ServersIpVersion `json:"ip_version"`
	IntervalSeconds        interface{}      `json:"interval_seconds"`
	IntervalSecondsTesting interface{}      `json:"interval_seconds_testing"`
	IntervalSecondsAll     interface{}      `json:"interval_seconds_all"`
	Limit                  int32            `json:"limit"`
	Offset                 int32            `json:"offset"`
}

type InsertLogScoreParams

type InsertLogScoreParams struct {
	ServerID   uint32          `json:"server_id"`
	MonitorID  sql.NullInt32   `json:"monitor_id"`
	Ts         time.Time       `json:"ts"`
	Score      float64         `json:"score"`
	Step       float64         `json:"step"`
	Offset     sql.NullFloat64 `json:"offset"`
	Rtt        sql.NullInt32   `json:"rtt"`
	Attributes sql.NullString  `json:"attributes"`
}

type InsertScorerParams

type InsertScorerParams struct {
	Name    string         `json:"name"`
	TlsName sql.NullString `json:"tls_name"`
}

type InsertScorerStatusParams

type InsertScorerStatusParams struct {
	ScorerID   uint32 `json:"scorer_id"`
	LogScoreID uint64 `json:"log_score_id"`
}

type InsertServerScoreParams

type InsertServerScoreParams struct {
	MonitorID uint32    `json:"monitor_id"`
	ServerID  uint32    `json:"server_id"`
	ScoreRaw  float64   `json:"score_raw"`
	CreatedOn time.Time `json:"created_on"`
}

type LogScore

type LogScore struct {
	ID         uint64          `json:"id"`
	MonitorID  sql.NullInt32   `json:"monitor_id"`
	ServerID   uint32          `json:"server_id"`
	Ts         time.Time       `json:"ts"`
	Score      float64         `json:"score"`
	Step       float64         `json:"step"`
	Offset     sql.NullFloat64 `json:"offset"`
	Rtt        sql.NullInt32   `json:"rtt"`
	Attributes sql.NullString  `json:"attributes"`
}

func (*LogScore) AbsoluteOffset

func (ls *LogScore) AbsoluteOffset() *time.Duration

func (*LogScore) MaxScore

func (ls *LogScore) MaxScore() (float64, bool)

type LogScoreAttributes

type LogScoreAttributes struct {
	Leap       int8   `json:"leap,omitempty"`
	Stratum    int8   `json:"stratum,omitempty"`
	NoResponse bool   `json:"no_response,omitempty"`
	Error      string `json:"error,omitempty"`
	Warning    string `json:"warning,omitempty"`

	FromLSID int `json:"from_ls_id,omitempty"`
	FromSSID int `json:"from_ss_id,omitempty"`
}

type Monitor

type Monitor struct {
	ID            uint32                `json:"id"`
	Type          MonitorsType          `json:"type"`
	UserID        sql.NullInt32         `json:"user_id"`
	AccountID     sql.NullInt32         `json:"account_id"`
	Name          string                `json:"name"`
	Location      string                `json:"location"`
	Ip            sql.NullString        `json:"ip"`
	IpVersion     NullMonitorsIpVersion `json:"ip_version"`
	TlsName       sql.NullString        `json:"tls_name"`
	ApiKey        sql.NullString        `json:"api_key"`
	Status        MonitorsStatus        `json:"status"`
	Config        string                `json:"config"`
	ClientVersion string                `json:"client_version"`
	LastSeen      sql.NullTime          `json:"last_seen"`
	LastSubmit    sql.NullTime          `json:"last_submit"`
	CreatedOn     time.Time             `json:"created_on"`
}

func (*Monitor) GetConfig

func (m *Monitor) GetConfig() (*MonitorConfig, error)

func (*Monitor) GetConfigWithDefaults

func (m *Monitor) GetConfigWithDefaults(defaults []byte) (*MonitorConfig, error)

func (*Monitor) IsLive

func (m *Monitor) IsLive() bool

type MonitorConfig

type MonitorConfig struct {
	Samples    int32    `json:"samples"`
	NatIP      string   `json:"nat_ip,omitempty"` // have the monitor bind to a different IP
	BaseChecks []string `json:"base_checks,omitempty"`

	MQTT *pb.MQTTConfig
	// contains filtered or unexported fields
}

func (*MonitorConfig) PbConfig

func (cfg *MonitorConfig) PbConfig() (*pb.Config, error)

type MonitorsIpVersion

type MonitorsIpVersion string
const (
	MonitorsIpVersionV4 MonitorsIpVersion = "v4"
	MonitorsIpVersionV6 MonitorsIpVersion = "v6"
)

func (*MonitorsIpVersion) Scan

func (e *MonitorsIpVersion) Scan(src interface{}) error

func (MonitorsIpVersion) String

func (mipv MonitorsIpVersion) String() string

type MonitorsStatus

type MonitorsStatus string
const (
	MonitorsStatusPending MonitorsStatus = "pending"
	MonitorsStatusTesting MonitorsStatus = "testing"
	MonitorsStatusActive  MonitorsStatus = "active"
	MonitorsStatusPaused  MonitorsStatus = "paused"
	MonitorsStatusDeleted MonitorsStatus = "deleted"
)

func (*MonitorsStatus) Scan

func (e *MonitorsStatus) Scan(src interface{}) error

type MonitorsType

type MonitorsType string
const (
	MonitorsTypeMonitor MonitorsType = "monitor"
	MonitorsTypeScore   MonitorsType = "score"
)

func (*MonitorsType) Scan

func (e *MonitorsType) Scan(src interface{}) error

type NullMonitorsIpVersion

type NullMonitorsIpVersion struct {
	MonitorsIpVersion MonitorsIpVersion `json:"monitors_ip_version"`
	Valid             bool              `json:"valid"` // Valid is true if MonitorsIpVersion is not NULL
}

func (*NullMonitorsIpVersion) Scan

func (ns *NullMonitorsIpVersion) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullMonitorsIpVersion) Value

func (ns NullMonitorsIpVersion) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullMonitorsStatus

type NullMonitorsStatus struct {
	MonitorsStatus MonitorsStatus `json:"monitors_status"`
	Valid          bool           `json:"valid"` // Valid is true if MonitorsStatus is not NULL
}

func (*NullMonitorsStatus) Scan

func (ns *NullMonitorsStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullMonitorsStatus) Value

func (ns NullMonitorsStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullMonitorsType

type NullMonitorsType struct {
	MonitorsType MonitorsType `json:"monitors_type"`
	Valid        bool         `json:"valid"` // Valid is true if MonitorsType is not NULL
}

func (*NullMonitorsType) Scan

func (ns *NullMonitorsType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullMonitorsType) Value

func (ns NullMonitorsType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullServerScoresStatus

type NullServerScoresStatus struct {
	ServerScoresStatus ServerScoresStatus `json:"server_scores_status"`
	Valid              bool               `json:"valid"` // Valid is true if ServerScoresStatus is not NULL
}

func (*NullServerScoresStatus) Scan

func (ns *NullServerScoresStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullServerScoresStatus) Value

func (ns NullServerScoresStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullServersIpVersion

type NullServersIpVersion struct {
	ServersIpVersion ServersIpVersion `json:"servers_ip_version"`
	Valid            bool             `json:"valid"` // Valid is true if ServersIpVersion is not NULL
}

func (*NullServersIpVersion) Scan

func (ns *NullServersIpVersion) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullServersIpVersion) Value

func (ns NullServersIpVersion) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) GetMonitorPriority

func (q *Queries) GetMonitorPriority(ctx context.Context, serverID uint32) ([]GetMonitorPriorityRow, error)

func (*Queries) GetMonitorTLSName

func (q *Queries) GetMonitorTLSName(ctx context.Context, tlsName sql.NullString) (Monitor, error)

func (*Queries) GetScorerLogScores

func (q *Queries) GetScorerLogScores(ctx context.Context, arg GetScorerLogScoresParams) ([]LogScore, error)

func (*Queries) GetScorerNextLogScoreID

func (q *Queries) GetScorerNextLogScoreID(ctx context.Context, logScoreID uint64) (uint64, error)

this is very slow when there's a backlog, so only run it when there are no results to make sure we don't get stuck behind a bunch of scoring ids. https://github.com/kyleconroy/sqlc/issues/1965

func (*Queries) GetScorerRecentScores

func (q *Queries) GetScorerRecentScores(ctx context.Context, arg GetScorerRecentScoresParams) ([]LogScore, error)

func (*Queries) GetScorerStatus

func (q *Queries) GetScorerStatus(ctx context.Context) ([]GetScorerStatusRow, error)

func (*Queries) GetScorers

func (q *Queries) GetScorers(ctx context.Context) ([]GetScorersRow, error)

func (*Queries) GetServer

func (q *Queries) GetServer(ctx context.Context, id uint32) (Server, error)

func (*Queries) GetServerIP

func (q *Queries) GetServerIP(ctx context.Context, ip string) (Server, error)

func (*Queries) GetServerScore

func (q *Queries) GetServerScore(ctx context.Context, arg GetServerScoreParams) (ServerScore, error)

func (*Queries) GetServers

func (q *Queries) GetServers(ctx context.Context, arg GetServersParams) ([]Server, error)

func (*Queries) GetServersMonitorReview

func (q *Queries) GetServersMonitorReview(ctx context.Context) ([]uint32, error)

func (*Queries) GetSystemMonitor

func (q *Queries) GetSystemMonitor(ctx context.Context, name string, ipVersion NullMonitorsIpVersion) (*SystemMonitor, error)

func (*Queries) GetSystemSetting

func (q *Queries) GetSystemSetting(ctx context.Context, key string) (string, error)

func (*Queries) InsertLogScore

func (q *Queries) InsertLogScore(ctx context.Context, arg InsertLogScoreParams) (sql.Result, error)

func (*Queries) InsertScorer

func (q *Queries) InsertScorer(ctx context.Context, arg InsertScorerParams) (sql.Result, error)

func (*Queries) InsertScorerStatus

func (q *Queries) InsertScorerStatus(ctx context.Context, arg InsertScorerStatusParams) error

func (*Queries) InsertServerScore

func (q *Queries) InsertServerScore(ctx context.Context, arg InsertServerScoreParams) error

func (*Queries) ListMonitors

func (q *Queries) ListMonitors(ctx context.Context) ([]Monitor, error)

func (*Queries) UpdateMonitorSeen

func (q *Queries) UpdateMonitorSeen(ctx context.Context, arg UpdateMonitorSeenParams) error

func (*Queries) UpdateMonitorSubmit

func (q *Queries) UpdateMonitorSubmit(ctx context.Context, arg UpdateMonitorSubmitParams) error

func (*Queries) UpdateMonitorVersion

func (q *Queries) UpdateMonitorVersion(ctx context.Context, arg UpdateMonitorVersionParams) error

func (*Queries) UpdateScorerStatus

func (q *Queries) UpdateScorerStatus(ctx context.Context, arg UpdateScorerStatusParams) error

func (*Queries) UpdateServer

func (q *Queries) UpdateServer(ctx context.Context, arg UpdateServerParams) error

func (*Queries) UpdateServerScore

func (q *Queries) UpdateServerScore(ctx context.Context, arg UpdateServerScoreParams) error

func (*Queries) UpdateServerScoreStatus

func (q *Queries) UpdateServerScoreStatus(ctx context.Context, arg UpdateServerScoreStatusParams) error

func (*Queries) UpdateServerScoreStratum

func (q *Queries) UpdateServerScoreStratum(ctx context.Context, arg UpdateServerScoreStratumParams) error

func (*Queries) UpdateServerStratum

func (q *Queries) UpdateServerStratum(ctx context.Context, arg UpdateServerStratumParams) error

func (*Queries) UpdateServersMonitorReview

func (q *Queries) UpdateServersMonitorReview(ctx context.Context, arg UpdateServersMonitorReviewParams) error

func (*Queries) UpdateServersMonitorReviewChanged

func (q *Queries) UpdateServersMonitorReviewChanged(ctx context.Context, arg UpdateServersMonitorReviewChangedParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type Server

type Server struct {
	ID             uint32           `json:"id"`
	Ip             string           `json:"ip"`
	IpVersion      ServersIpVersion `json:"ip_version"`
	UserID         uint32           `json:"user_id"`
	AccountID      sql.NullInt32    `json:"account_id"`
	Hostname       sql.NullString   `json:"hostname"`
	Stratum        sql.NullInt32    `json:"stratum"`
	InPool         uint32           `json:"in_pool"`
	InServerList   uint32           `json:"in_server_list"`
	Netspeed       uint32           `json:"netspeed"`
	NetspeedTarget uint32           `json:"netspeed_target"`
	CreatedOn      time.Time        `json:"created_on"`
	UpdatedOn      time.Time        `json:"updated_on"`
	ScoreTs        sql.NullTime     `json:"score_ts"`
	ScoreRaw       float64          `json:"score_raw"`
	DeletionOn     sql.NullTime     `json:"deletion_on"`
	Flags          string           `json:"flags"`
}

type ServerScore

type ServerScore struct {
	ID         uint64             `json:"id"`
	MonitorID  uint32             `json:"monitor_id"`
	ServerID   uint32             `json:"server_id"`
	ScoreTs    sql.NullTime       `json:"score_ts"`
	ScoreRaw   float64            `json:"score_raw"`
	Stratum    sql.NullInt32      `json:"stratum"`
	Status     ServerScoresStatus `json:"status"`
	CreatedOn  time.Time          `json:"created_on"`
	ModifiedOn time.Time          `json:"modified_on"`
}

type ServerScoresStatus

type ServerScoresStatus string
const (
	ServerScoresStatusNew     ServerScoresStatus = "new"
	ServerScoresStatusTesting ServerScoresStatus = "testing"
	ServerScoresStatusActive  ServerScoresStatus = "active"
)

func (*ServerScoresStatus) Scan

func (e *ServerScoresStatus) Scan(src interface{}) error

type ServersIpVersion

type ServersIpVersion string
const (
	ServersIpVersionV4 ServersIpVersion = "v4"
	ServersIpVersionV6 ServersIpVersion = "v6"
)

func (*ServersIpVersion) Scan

func (e *ServersIpVersion) Scan(src interface{}) error

type SystemMonitor

type SystemMonitor struct {
	Monitor
}

type UpdateMonitorSeenParams

type UpdateMonitorSeenParams struct {
	LastSeen sql.NullTime `json:"last_seen"`
	ID       uint32       `json:"id"`
}

type UpdateMonitorSubmitParams

type UpdateMonitorSubmitParams struct {
	LastSubmit sql.NullTime `json:"last_submit"`
	LastSeen   sql.NullTime `json:"last_seen"`
	ID         uint32       `json:"id"`
}

type UpdateMonitorVersionParams

type UpdateMonitorVersionParams struct {
	ClientVersion string `json:"client_version"`
	ID            uint32 `json:"id"`
}

type UpdateScorerStatusParams

type UpdateScorerStatusParams struct {
	LogScoreID uint64 `json:"log_score_id"`
	ScorerID   uint32 `json:"scorer_id"`
}

type UpdateServerParams

type UpdateServerParams struct {
	ScoreTs  sql.NullTime `json:"score_ts"`
	ScoreRaw float64      `json:"score_raw"`
	ID       uint32       `json:"id"`
}

type UpdateServerScoreParams

type UpdateServerScoreParams struct {
	ScoreTs  sql.NullTime `json:"score_ts"`
	ScoreRaw float64      `json:"score_raw"`
	ID       uint64       `json:"id"`
}

type UpdateServerScoreStatusParams

type UpdateServerScoreStatusParams struct {
	Status    ServerScoresStatus `json:"status"`
	MonitorID uint32             `json:"monitor_id"`
	ServerID  uint32             `json:"server_id"`
}

type UpdateServerScoreStratumParams

type UpdateServerScoreStratumParams struct {
	Stratum sql.NullInt32 `json:"stratum"`
	ID      uint64        `json:"id"`
}

type UpdateServerStratumParams

type UpdateServerStratumParams struct {
	Stratum sql.NullInt32 `json:"stratum"`
	ID      uint32        `json:"id"`
}

type UpdateServersMonitorReviewChangedParams

type UpdateServersMonitorReviewChangedParams struct {
	NextReview sql.NullTime `json:"next_review"`
	ServerID   uint32       `json:"server_id"`
}

type UpdateServersMonitorReviewParams

type UpdateServersMonitorReviewParams struct {
	NextReview sql.NullTime `json:"next_review"`
	ServerID   uint32       `json:"server_id"`
}

Jump to

Keyboard shortcuts

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