query

package
v0.466.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec[Req any](ctx context.Context, dbName string, rawSQL string, params []any, colFieldNames []tuple.Pair[string, string]) error

func Many

func Many[Req, Resp any](ctx context.Context, dbName string, rawSQL string, params []any, colFieldNames []tuple.Pair[string, string]) ([]Resp, error)

func One

func One[Req, Resp any](ctx context.Context, dbName string, rawSQL string, params []any, colFieldNames []tuple.Pair[string, string]) (resp Resp, err error)

Types

type DB

type DB interface {
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}

DB represents a database that can execute queries

type Service

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

Service proxies query requests to multiple database instances

func New

func New(ctx context.Context, module *schema.Module, addresses *xsync.MapOf[string, string]) (*Service, error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) Ping

func (*Service) UpdateConnections added in v0.464.0

func (s *Service) UpdateConnections(ctx context.Context, module *schema.Module, addresses *xsync.MapOf[string, string]) error

UpdateConnections updates the connections based on a new module and addresses during hot reloading. It fails if any database has configuration or connection issues.

Jump to

Keyboard shortcuts

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