database

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: PostgreSQL Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Source = catalogKey("source")
	Target = catalogKey("target")
)
View Source
var (
	SourceConnect int
	TargetConnect int
)

Functions

func Close

func Close()

Close waits for connection releases and close them

func Connection

func Connection(ctx context.Context, key catalogKey) *sql.Conn

Connection return SQL connection from context

panics if context does not have a connection.

func Execute

func Execute(ctx context.Context, id string, sn int, query string, stdin io.Reader, msg string, logArgs ...any) error

Execute immediatly a query

Uses query executor to send query to stdout, files or Postgres.

func ExecuteTask

func ExecuteTask(id string, priority int, reqs []string, query, message string, logArgs ...any) dispatch.Task

ExecuteTask instanciate a dispatch task for a single query

func Forget added in v0.28.0

func Forget(ctx context.Context, key catalogKey) context.Context

Forget hides connection from context.

Use WithConnection to create a new connection in returned context.

func SetupExecution

func SetupExecution(f Executer)

SetupExecution saves query executor

func WaitReleased

func WaitReleased()

WaitReleased waits for all connection to close.

func WithConnection

func WithConnection(ctx context.Context, key catalogKey) (context.Context, error)

WithConnection ensure context has a db connection

Connection is released when context is done. You should defer cancel() func before adding connexion to context.

Use Connection() to get connection on success.

Types

type Executer

type Executer interface {
	// contains filtered or unexported methods
}

func FileExecutor

func FileExecutor(directory string) Executer

FileExecutor writes queries to files.

File order depends on scheduling. Creates directory if not exists. Does not clean directory.

func PostgresExecutor

func PostgresExecutor() Executer

PostgresExecutor sends queries to Postgres.

Requires a Target connection in context as set by WithConnection.

func StreamExecutor

func StreamExecutor(w io.Writer) Executer

StreamExecutor writes queries to stream. Prevents concurrent writes.

Jump to

Keyboard shortcuts

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