database

package
v0.2.0-beta-8 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As400DateExpr

func As400DateExpr(col string) string

As400DateExpr returns a guarded DATE expression for 6-digit AS/400 numeric dates.

func DecodeRows

func DecodeRows[T any](rows []types.ResultRow) ([]T, error)

DecodeRows maps a slice of types.ResultRow to a typed slice using mapstructure.

Types

type DB

type DB interface {
	StartJDBCRunner() error
	StopJDBCRunner() error
	Connect(ctx context.Context) error
	Disconnect(ctx context.Context) error
	// PingService checks that the Java TCP service is running.
	PingService(ctx context.Context) error
	// PingDatabase checks that the Java service is connected to the AS/400 database.
	PingDatabase(ctx context.Context) error
	Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	Query(ctx context.Context, query string, args ...interface{}) ([]types.ResultRow, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) (types.ResultRow, error)
	Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	QueryWithSource(ctx context.Context, query string, args ...interface{}) ([]types.ResultRow, error)
}

DB defines the operations for interacting with the AS/400 database service. It includes lifecycle control, health checks, and standard CRUD-style querying methods.

func BindTenant

func BindTenant(mt MultiTenantDB, tenant string) DB

BindTenant returns a DB that forwards calls to the provided MultiTenantDB using tenant.

type IBMi400

type IBMi400 struct {
	JDBCRunner *JDBCRunnerService
	Config     *types.DISConfig
	Logger     *slog.Logger
}

IBMi400 is a Go wrapper around JDBCRunnerService, exposing high-level database methods.

func NewIBMi400

func NewIBMi400(config *types.DISConfig, logger *slog.Logger) *IBMi400

NewIBMi400 constructs an IBMi400 given configuration and logger.

func (*IBMi400) Connect

func (ds *IBMi400) Connect(ctx context.Context) error

Connect establishes a new TCP connection to the JDBC runner, sending a connect command and verifying the response.

func (*IBMi400) Disconnect

func (ds *IBMi400) Disconnect(ctx context.Context) error

Disconnect sends a disconnect command to close the connection pool.

func (*IBMi400) Get

func (ds *IBMi400) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Get executes a single-row query and decodes the result into dest.

func (*IBMi400) PingDatabase

func (ds *IBMi400) PingDatabase(ctx context.Context) error

PingDatabase performs a health check ensuring the Java service is connected to the database.

func (*IBMi400) PingService

func (ds *IBMi400) PingService(ctx context.Context) error

PingService checks the Java service process is alive and responding to commands.

func (*IBMi400) Query

func (ds *IBMi400) Query(ctx context.Context, query string, args ...interface{}) ([]types.ResultRow, error)

Query executes a SQL query that may return multiple rows.

func (*IBMi400) QueryRow

func (ds *IBMi400) QueryRow(ctx context.Context, query string, args ...interface{}) (types.ResultRow, error)

QueryRow executes a SQL query expected to return exactly one row.

func (*IBMi400) QueryWithSource

func (ds *IBMi400) QueryWithSource(ctx context.Context, query string, args ...interface{}) ([]types.ResultRow, error)

QueryWithSource executes a SQL query with src_table included on each row.

func (*IBMi400) Select

func (ds *IBMi400) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Select executes the query and decodes all rows into dest.

func (*IBMi400) StartJDBCRunner

func (ds *IBMi400) StartJDBCRunner() error

StartJDBCRunner launches the Java JDBC runner process and waits until it's ready.

func (*IBMi400) StopJDBCRunner

func (ds *IBMi400) StopJDBCRunner() error

StopJDBCRunner terminates the Java JDBC runner process.

type JDBCRunnerService

type JDBCRunnerService struct {
	Logger *slog.Logger
	// contains filtered or unexported fields
}

func NewJDBCRunnerService

func NewJDBCRunnerService(config *types.DISConfig, logger *slog.Logger) *JDBCRunnerService

func (*JDBCRunnerService) Connect

func (j *JDBCRunnerService) Connect(ctx context.Context) error

func (*JDBCRunnerService) Disconnect

func (j *JDBCRunnerService) Disconnect(ctx context.Context) error

Disconnect sends a disconnect command to the Java server to close the pool.

func (*JDBCRunnerService) PingDatabase

func (j *JDBCRunnerService) PingDatabase(ctx context.Context) error

PingDatabase checks that the Java service is connected to the database.

func (*JDBCRunnerService) PingService

func (j *JDBCRunnerService) PingService(ctx context.Context) error

PingService checks that the Java service process is alive and responding to commands.

func (*JDBCRunnerService) Query

func (j *JDBCRunnerService) Query(ctx context.Context, sql string) ([]types.ResultRow, error)

func (*JDBCRunnerService) Shutdown

func (j *JDBCRunnerService) Shutdown()

func (*JDBCRunnerService) Start

func (j *JDBCRunnerService) Start() error

type MultiTenantDB

type MultiTenantDB interface {
	StartJDBCRunner(tenant string) error
	StopJDBCRunner(tenant string) error
	Connect(ctx context.Context, tenant string) error
	Disconnect(ctx context.Context, tenant string) error
	PingService(ctx context.Context, tenant string) error
	PingDatabase(ctx context.Context, tenant string) error
	Get(ctx context.Context, dest interface{}, query string, tenant string, args ...interface{}) error
	Query(ctx context.Context, query string, tenant string, args ...interface{}) ([]types.ResultRow, error)
	QueryRow(ctx context.Context, query string, tenant string, args ...interface{}) (types.ResultRow, error)
	Select(ctx context.Context, dest interface{}, query string, tenant string, args ...interface{}) error
	QueryWithSource(ctx context.Context, query string, tenant string, args ...interface{}) ([]types.ResultRow, error)
}

MultiTenantDB mirrors DB but requires the caller to supply a tenant string. This is used by remote mode, while domain code continues to depend on DB.

type RemoteDB

type RemoteDB struct {
	Logger *slog.Logger
	// contains filtered or unexported fields
}

RemoteDB satisfies the MultiTenantDB interface by proxying calls to a remote agent over the bridge.

func NewRemoteDB

func NewRemoteDB(registry bridge.AgentRegistry, logger *slog.Logger, maxRows int, maxBytes int64) *RemoteDB

func (*RemoteDB) Connect

func (r *RemoteDB) Connect(ctx context.Context, tenant string) error

func (*RemoteDB) Disconnect

func (r *RemoteDB) Disconnect(ctx context.Context, tenant string) error

func (*RemoteDB) Get

func (r *RemoteDB) Get(ctx context.Context, dest interface{}, query string, tenant string, args ...interface{}) error

func (*RemoteDB) PingDatabase

func (r *RemoteDB) PingDatabase(ctx context.Context, tenant string) error

func (*RemoteDB) PingService

func (r *RemoteDB) PingService(ctx context.Context, tenant string) error

func (*RemoteDB) Query

func (r *RemoteDB) Query(ctx context.Context, query string, tenant string, args ...interface{}) ([]types.ResultRow, error)

func (*RemoteDB) QueryRow

func (r *RemoteDB) QueryRow(ctx context.Context, query string, tenant string, args ...interface{}) (types.ResultRow, error)

func (*RemoteDB) QueryWithSource

func (r *RemoteDB) QueryWithSource(ctx context.Context, query string, tenant string, args ...interface{}) ([]types.ResultRow, error)

func (*RemoteDB) Select

func (r *RemoteDB) Select(ctx context.Context, dest interface{}, query string, tenant string, args ...interface{}) error

func (*RemoteDB) StartJDBCRunner

func (r *RemoteDB) StartJDBCRunner(tenant string) error

Lifecycle control delegates to remote agent per tenant.

func (*RemoteDB) StopJDBCRunner

func (r *RemoteDB) StopJDBCRunner(tenant string) error

Jump to

Keyboard shortcuts

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