Documentation
¶
Index ¶
- func As400DateExpr(col string) string
- func DecodeRows[T any](rows []types.ResultRow) ([]T, error)
- type DB
- type IBMi400
- func (ds *IBMi400) Connect(ctx context.Context) error
- func (ds *IBMi400) Disconnect(ctx context.Context) error
- func (ds *IBMi400) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (ds *IBMi400) PingDatabase(ctx context.Context) error
- func (ds *IBMi400) PingService(ctx context.Context) error
- func (ds *IBMi400) Query(ctx context.Context, query string, args ...interface{}) ([]types.ResultRow, error)
- func (ds *IBMi400) QueryRow(ctx context.Context, query string, args ...interface{}) (types.ResultRow, error)
- func (ds *IBMi400) QueryWithSource(ctx context.Context, query string, args ...interface{}) ([]types.ResultRow, error)
- func (ds *IBMi400) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (ds *IBMi400) StartJDBCRunner() error
- func (ds *IBMi400) StopJDBCRunner() error
- type JDBCRunnerService
- func (j *JDBCRunnerService) Connect(ctx context.Context) error
- func (j *JDBCRunnerService) Disconnect(ctx context.Context) error
- func (j *JDBCRunnerService) PingDatabase(ctx context.Context) error
- func (j *JDBCRunnerService) PingService(ctx context.Context) error
- func (j *JDBCRunnerService) Query(ctx context.Context, sql string) ([]types.ResultRow, error)
- func (j *JDBCRunnerService) Shutdown()
- func (j *JDBCRunnerService) Start() error
- type MultiTenantDB
- type RemoteDB
- func (r *RemoteDB) Connect(ctx context.Context, tenant string) error
- func (r *RemoteDB) Disconnect(ctx context.Context, tenant string) error
- func (r *RemoteDB) Get(ctx context.Context, dest interface{}, query string, tenant string, ...) error
- func (r *RemoteDB) PingDatabase(ctx context.Context, tenant string) error
- func (r *RemoteDB) PingService(ctx context.Context, tenant string) error
- func (r *RemoteDB) Query(ctx context.Context, query string, tenant string, args ...interface{}) ([]types.ResultRow, error)
- func (r *RemoteDB) QueryRow(ctx context.Context, query string, tenant string, args ...interface{}) (types.ResultRow, error)
- func (r *RemoteDB) QueryWithSource(ctx context.Context, query string, tenant string, args ...interface{}) ([]types.ResultRow, error)
- func (r *RemoteDB) Select(ctx context.Context, dest interface{}, query string, tenant string, ...) error
- func (r *RemoteDB) StartJDBCRunner(tenant string) error
- func (r *RemoteDB) StopJDBCRunner(tenant string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func As400DateExpr ¶
As400DateExpr returns a guarded DATE expression for 6-digit AS/400 numeric dates.
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 ¶
NewIBMi400 constructs an IBMi400 given configuration and logger.
func (*IBMi400) Connect ¶
Connect establishes a new TCP connection to the JDBC runner, sending a connect command and verifying the response.
func (*IBMi400) Disconnect ¶
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 ¶
PingDatabase performs a health check ensuring the Java service is connected to the database.
func (*IBMi400) PingService ¶
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 ¶
StartJDBCRunner launches the Java JDBC runner process and waits until it's ready.
func (*IBMi400) StopJDBCRunner ¶
StopJDBCRunner terminates the Java JDBC runner process.
type JDBCRunnerService ¶
func NewJDBCRunnerService ¶
func NewJDBCRunnerService(config *types.DISConfig, logger *slog.Logger) *JDBCRunnerService
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) 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 ¶
RemoteDB satisfies the MultiTenantDB interface by proxying calls to a remote agent over the bridge.
func NewRemoteDB ¶
func (*RemoteDB) Disconnect ¶
func (*RemoteDB) PingDatabase ¶
func (*RemoteDB) PingService ¶
func (*RemoteDB) QueryWithSource ¶
func (*RemoteDB) StartJDBCRunner ¶
Lifecycle control delegates to remote agent per tenant.