database

package
v1.0.0-beta.10 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: PostgreSQL Imports: 18 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, statement string, stdin io.Reader, msg string, logArgs ...any) error

Execute immediatly a SQL statement

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

func ExecuteSourceTask added in v1.0.0

func ExecuteSourceTask(id string, reqs []string, statement, message string) executeSourceTask

ExecuteSourceTask instanciate a dispatch task for a single statement on source

func ExecuteTask

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

ExecuteTask instanciate a dispatch task for a single statement

Use SetupExecution to globally configure query execution.

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 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.

func TreeExecutor added in v1.0.0

func TreeExecutor(directory string) Executer

TreeExecutor writes queries to files.

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

Jump to

Keyboard shortcuts

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