pgnet

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(ctx context.Context, conn RegisterConn) error

Types

type DBQuerier

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

func NewQuerier

func NewQuerier(ctx context.Context, conn genericConn) (*DBQuerier, error)

NewQuerier creates a DBQuerier that implements Querier.

func (*DBQuerier) FindServerByIP

func (q *DBQuerier) FindServerByIP(ctx context.Context, ipAddress *net.IPNet) (FindServerByIPRow, error)

FindServerByIP implements Querier.FindServerByIP.

func (*DBQuerier) FindServers

func (q *DBQuerier) FindServers(ctx context.Context) ([]FindServersRow, error)

FindServers implements Querier.FindServers.

func (*DBQuerier) InsertServer

func (q *DBQuerier) InsertServer(ctx context.Context, ipAddress *net.IPNet, extraIpAddress *net.IPNet) (int32, error)

InsertServer implements Querier.InsertServer.

type FindServerByIPRow

type FindServerByIPRow struct {
	ID             int32      `json:"id"`
	IpAddress      *net.IPNet `json:"ip_address"`
	ExtraIpAddress *net.IPNet `json:"extra_ip_address"`
}

type FindServersRow

type FindServersRow struct {
	ID             *int32     `json:"id"`
	IpAddress      *net.IPNet `json:"ip_address"`
	ExtraIpAddress *net.IPNet `json:"extra_ip_address"`
}

type Querier

type Querier interface {
	// FindServers finds all servers.
	FindServers(ctx context.Context) ([]FindServersRow, error)

	// FindServerByIP finds a server by its ip address.
	FindServerByIP(ctx context.Context, ipAddress *net.IPNet) (FindServerByIPRow, error)

	// InsertServer inserts a server and returns the ID.
	InsertServer(ctx context.Context, ipAddress *net.IPNet, extraIpAddress *net.IPNet) (int32, error)
}

Querier is a typesafe Go interface backed by SQL queries.

type RegisterConn

type RegisterConn interface {
	LoadType(ctx context.Context, typeName string) (*pgtype.Type, error)
	TypeMap() *pgtype.Map
}

Jump to

Keyboard shortcuts

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