// STRYKE-MYSQL — ENGINEERING REPORT

Opt-in stryke connector package · cdylib libstryke_mysql.{dylib,so} (crate-type = cdylib) · dlopen'd in-process on use MySQL · JSON-over-FFI envelope

>_EXECUTIVE SUMMARY

stryke-mysql is one of the opt-in connector packages in the stryke ecosystem. MySQL / MariaDB client for stryke. Opt-in package, kept out of the stryke core binary so the daily-driver install stays slim. The mysql driver ships as a Rust cdylib that stryke dlopens in-process on first use MySQL.

The mysql crate pulls in a native libmysql-style protocol stack + TLS chains. Ships once as an opt-in package.

cdylib
Crate type
opt-in
Tier
dlopen
Load model
JSON-over-FFI
Envelope
77
MySQL::* functions
66
mysql__* FFI exports
v0.21.0
Package version
Pool/URL
Connection cache

~ARCHITECTURE

In-process cdylib design: the stryke side is a thin .stk wrapper that calls FFI symbols on the dlopen'd library. No subprocess, no pipe — calls return on the same thread that made them.

LayerImplementation
stryke wrappers (lib/*.stk)Thin .stk wrapper (MySQL); exposes typed helpers that serialize args to JSON and parse the response
cdylib (libstryke_mysql.{dylib,so})Single Rust cdylib crate; every public surface fn is an extern "C" fn mysql__<verb>(*const c_char) -> *mut c_char (query/introspection verbs + connection-free DSN/quoting helpers; authoritative list in stryke.toml)
Process modelLibrary is dlopen'd once per stryke session on first use MySQL; a mysql::Pool cache keyed by connection URL held in OnceCell; lives until the runtime exits
BuildCargo with [lib] crate-type = ["cdylib"]; publish = false; the package itself ships via s pkg install -g .
Install path~/.stryke/store/mysql@<version>/ after make install; use MySQL from any stryke script resolves it
Testszunit-style under t/ with live-service variants when applicable
CIGitHub Actions .github/workflows/ci.ymlcargo check + fmt --check + clippy -D warnings + test, plus a Stryke .stk suite job that builds the cdylib, installs the package, and runs t/ against a live MySQL service

$WHY OPT-IN (NOT BUILTIN)

The mysql crate pulls in a native libmysql-style protocol stack + TLS chains. Ships once as an opt-in package.

The trade-off is intentional. The core stryke binary stays under ~40 MB precisely because each connector ships separately. Daily-driver work (one-liners, awk replacement, data scripting) doesn't need MongoDB drivers, AWS SDKs, or Spark Connect bindings linked in.


&FFI ENVELOPE

JSON in / JSON out across the FFI boundary. Each MySQL::* wrapper serializes its args to a JSON dict and calls the matching mysql__* symbol on the dlopen'd cdylib; the cdylib returns a JSON CString the wrapper parses. catch_unwind on every call converts panics to JSON errors. The returned CString is freed via the cdylib-exported stryke_free_cstring, wired automatically by rust_ffi::load_cdylib. A mysql::Pool cache keyed by connection URL is held in OnceCell, so back-to-back calls reuse the same connection pool.

# request shape (built by the .stk wrapper)
{"<arg>": ...}

# response shape
{"result": ...}            # success — per-fn shape
{"error": "<msg>"}        # failure — wrapper die()s with the message

@FUNCTION SURFACE

The stryke side (lib/MySQL.stk) exposes 77 public MySQL::* functions. Most connection-aware verbs map 1:1 to a mysql__* FFI export; the higher-level CRUD helpers and several read shapes are composed on the stryke side, which is why there are more functions (77) than exports (66).

GroupFunctions
Readquery, query_one, query_col, query_scalar, query_stream, query_multi, call, dump
Write / CRUDexecute, exec_file, insert_many, upsert, update, delete, truncate, count, exists, table_exists
Transactionstransaction (one connection, real START TRANSACTION, all-or-nothing)
Introspectiondatabases, tables, views, schema, columns, column_names, indexes, foreign_keys, create_table, procedures, triggers, events, charsets, collations, engines
Admin / observabilityping, users, grants, status, variables, processlist, kill, db_size, table_size, explain, current_database, create_database, drop_database
Versionversion (cdylib build), server_version (live SELECT VERSION())
Pure helpers (no connection)DSN (parse_dsn/build_dsn/redact_dsn), identifiers (quote_ident/unquote_ident/quote_qualified_ident/parse_qualified_ident), literals (quote_literal/unquote_literal/quote/escape_string), LIKE (escape_like/unescape_like/like_pattern), IN lists (format_in_list/parse_in_list), ENUM/SET (parse_enum/build_enum/enum_index/enum_value/set_mask/set_from_mask/parse_set_value), types (parse_column_type/normalize_type), builders (format_assignments/format_placeholders/build_where_eq)

+DEPENDENCIES

The cdylib keeps a deliberately small, foundational dependency set. The release profile is tuned for a compact shippable artifact (opt-level = 3, lto = "thin", codegen-units = 1, strip = true, panic = "abort").

CrateVersionRole
mysql28 (minimal-rust, buffer-pool, client_ed25519)MySQL / MariaDB protocol driver + connection pool
serde / serde_json1 (preserve_order)JSON-over-FFI envelope encode/decode
chrono0.4 (clock, std)DATE / DATETIME / TIME formatting
once_cell1process-lifetime mysql::Pool cache
parking_lot0.12locking for the pool cache
anyhow1error propagation inside the cdylib

^TYPE ENCODING

Result rows cross the FFI boundary as JSON. Integer/float types become JSON numbers; DECIMAL is a string (the protocol sends it as bytes); DATE/DATETIME/TIMESTAMP/TIME become formatted strings; JSON columns are returned as raw JSON text; NULL becomes null. A BLOB/VARBINARY value is a string when it is valid UTF-8, otherwise it is prefixed "base64:" so consumers can detect and decode it. The full table is in the README "Type encoding" section.


/SCOPE

See the README's "Why this is a package" + "API reference" sections for the authoritative scope. The package is intentionally narrower than its underlying SDK / driver — the goal is "useful from a shell pipeline", not "complete API coverage". The connector currently exposes 77 stryke functions over 66 FFI exports, covering query, CRUD, transactions, introspection, admin, and connection-free SQL helpers. There is no separate CLI binary — the surface is the use MySQL package; the historical stryke-mysql-helper fork-per-call binary and its JSON-RPC daemon mode were replaced by the in-process cdylib + pool cache.


#PROJECT METADATA

ItemValue
LicenseMIT
AuthorMenkeTechnologies
Repositorygithub.com/MenkeTechnologies/stryke-mysql
Parent languagestrykelang
Meta umbrellaMenkeTechnologiesMeta
Issuesgithub.com/MenkeTechnologies/stryke-mysql/issues