Documentation
¶
Overview ¶
Package sqlchan is Bindle's SQL channel to an IBM i host: run SQL and read structured results, alongside the SSH/CL transport.
The MVP backend drives the open-source db2util (PASE, installable via yum and present on pub400) over the existing SSH transport: it runs DDL/DML and returns query result sets as JSON. The Conn interface keeps room for a mapepire backend later without touching callers (e.g. migrations).
Index ¶
Constants ¶
const ControlTable = "BINDLE_MIGRATIONS"
ControlTable is the per-schema table tracking applied migrations.
const DefaultDb2util = "/QOpenSys/pkgs/bin/db2util"
DefaultDb2util is the usual PASE path of db2util.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChecksumMismatchError ¶
type ChecksumMismatchError struct {
ID, Was, Now string
}
ChecksumMismatchError means an already-applied migration's file changed — published migrations must be immutable.
func (*ChecksumMismatchError) Error ¶
func (e *ChecksumMismatchError) Error() string
type Conn ¶
type Conn interface {
// Exec runs a statement with no result set (DDL/DML).
Exec(stmt string) error
// Query runs a statement and returns its rows.
Query(stmt string) ([]Row, error)
}
Conn runs SQL against an IBM i host.
type Db2util ¶
type Db2util struct {
// contains filtered or unexported fields
}
Db2util is a Conn backed by the db2util CLI over SSH.
func NewDb2util ¶
NewDb2util returns a db2util-backed connection. An empty bin uses the default path.
type Mapepire ¶
type Mapepire struct {
// contains filtered or unexported fields
}
Mapepire is a Conn backed by the mapepire-server WebSocket protocol.
func DialMapepire ¶
func DialMapepire(ctx context.Context, opts MapepireOptions) (*Mapepire, error)
DialMapepire opens a mapepire connection over the tunnel.
type MapepireOptions ¶
type MapepireOptions struct {
Tunnel Tunnel // how to reach the daemon (SSH direct-tcpip)
Host string // host name as the daemon sees it (default "localhost")
Port int // daemon port (default 8076)
User string
Password string
Insecure bool // accept the daemon's self-signed cert (default true)
Timeout time.Duration // per-request timeout (default 30s)
}
MapepireOptions configures a mapepire connection.
type Migration ¶
type Migration struct {
ID string // filename without extension, e.g. "0001_init"
Path string
Checksum string // sha256 hex of the file contents
}
Migration is one versioned DDL/DML file.
func LoadMigrations ¶
LoadMigrations reads *.sql files from dir, sorted lexicographically by name.
type MigrationResult ¶
type MigrationResult struct {
Applied []string // ids applied this run, in order
Skipped []string // ids already applied
}
MigrationResult records what Migrate did.