db

package
v0.0.0-...-3e92949 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Schema string

Functions

func OpenReadWrite

func OpenReadWrite(ctx context.Context, dbFile string, opts OpenOptions) (rdb *sql.DB, wdb *sql.DB, err error)

func RegisterPragmaHook

func RegisterPragmaHook(cacheSize int)

Types

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 GetNodeAddressParams

type GetNodeAddressParams struct {
	PublicKey *PublicKey
	Net       string
	Ip        string
	Port      int64
}

type GetNodeByInfoResponseAddressParams

type GetNodeByInfoResponseAddressParams struct {
	Net            string
	Ip             string
	Port           int64
	InfoReqTimeout float64
}

type GetNodeByInfoResponseAddressRow

type GetNodeByInfoResponseAddressRow struct {
	Node        Node
	NodeAddress NodeAddress
}

type GetNodeByPublicKeyRow

type GetNodeByPublicKeyRow struct {
	Node        Node
	NodeAddress NodeAddress
}

type GetNodesWithStaleBootstrapInfoParams

type GetNodesWithStaleBootstrapInfoParams struct {
	NodeTimeout  float64
	InfoInterval float64
}

type GetNodesWithStaleBootstrapInfoRow

type GetNodesWithStaleBootstrapInfoRow struct {
	Node        Node
	NodeAddress NodeAddress
}

type GetResponsiveNodesRow

type GetResponsiveNodesRow struct {
	Node        Node
	NodeAddress NodeAddress
}

type GetUnresponsiveNodesRow

type GetUnresponsiveNodesRow struct {
	Node        Node
	NodeAddress NodeAddress
}

type Node

type Node struct {
	ID            int64
	CreatedAt     Time
	LastSeenAt    Time
	LastInfoReqAt Time
	LastInfoResAt Time
	PublicKey     *PublicKey
	Fqdn          sql.NullString
	Motd          sql.NullString
	Version       sql.NullInt64
}

type NodeAddress

type NodeAddress struct {
	ID         int64
	CreatedAt  Time
	LastSeenAt Time
	LastPingAt Time
	LastPongAt Time
	NodeID     int64
	Net        string
	Ip         string
	Port       int64
	Ptr        sql.NullString
}

type OpenOptions

type OpenOptions struct {
	Params map[string]string
}

type PublicKey

type PublicKey dht.PublicKey

func (*PublicKey) Scan

func (k *PublicKey) Scan(src any) error

Scan implements the sql.Scanner interface.

func (*PublicKey) Value

func (k *PublicKey) 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) GetNodeAddress

func (q *Queries) GetNodeAddress(ctx context.Context, arg *GetNodeAddressParams) (int64, error)

func (*Queries) GetNodeByPublicKey

func (q *Queries) GetNodeByPublicKey(ctx context.Context, publicKey *PublicKey) ([]*GetNodeByPublicKeyRow, error)

func (*Queries) GetNodeCount

func (q *Queries) GetNodeCount(ctx context.Context) (int64, error)

func (*Queries) GetResponsiveNodes

func (q *Queries) GetResponsiveNodes(ctx context.Context) ([]*GetResponsiveNodesRow, error)

func (*Queries) GetUnresponsiveNodes

func (q *Queries) GetUnresponsiveNodes(ctx context.Context, retryDelay float64) ([]*GetUnresponsiveNodesRow, error)

func (*Queries) HasNodeByPublicKey

func (q *Queries) HasNodeByPublicKey(ctx context.Context, publicKey *PublicKey) (int64, error)

func (*Queries) PingNodeAddress

func (q *Queries) PingNodeAddress(ctx context.Context, id int64) error

func (*Queries) PongNodeAddress

func (q *Queries) PongNodeAddress(ctx context.Context, id int64) error

func (*Queries) UpdateNodeAddress

func (q *Queries) UpdateNodeAddress(ctx context.Context, arg *UpdateNodeAddressParams) (*NodeAddress, error)

func (*Queries) UpdateNodeBootstrapInfo

func (q *Queries) UpdateNodeBootstrapInfo(ctx context.Context, arg *UpdateNodeBootstrapInfoParams) error

func (*Queries) UpdateNodeInfoRequestTime

func (q *Queries) UpdateNodeInfoRequestTime(ctx context.Context, arg *UpdateNodeInfoRequestTimeParams) error

func (*Queries) UpsertNode

func (q *Queries) UpsertNode(ctx context.Context, publicKey *PublicKey) (*Node, error)

func (*Queries) UpsertNodeAddress

func (q *Queries) UpsertNodeAddress(ctx context.Context, arg *UpsertNodeAddressParams) (*NodeAddress, error)

func (*Queries) WithTx

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

type Time

type Time time.Time

func (*Time) Scan

func (t *Time) Scan(src any) error

Scan implements the sql.Scanner interface.

func (Time) Value

func (t Time) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type UpdateNodeAddressParams

type UpdateNodeAddressParams struct {
	NodeID int64
	Net    string
	Ip     string
	Port   int64
	Ptr    sql.NullString
	ID     int64
}

type UpdateNodeBootstrapInfoParams

type UpdateNodeBootstrapInfoParams struct {
	Motd      sql.NullString
	Version   sql.NullInt64
	PublicKey *PublicKey
}

type UpdateNodeInfoRequestTimeParams

type UpdateNodeInfoRequestTimeParams struct {
	LastInfoReqAt Time
	ID            int64
}

type UpsertNodeAddressParams

type UpsertNodeAddressParams struct {
	NodeID int64
	Net    string
	Ip     string
	Port   int64
	Ptr    sql.NullString
}

Jump to

Keyboard shortcuts

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