Documentación/Custom driver example
Esta página aún no está traducida. Se muestra la versión en inglés. Ver en inglés
Custom Driver Example
This example is a standalone driver host that speaks the DBFlux Driver RPC protocol.
It is intentionally small and in-memory, so you can verify the integration flow end-to-end before implementing a real database backend.
What it implements
- Hello handshake (with
driver_kindanddriver_metadata) - Driver-defined form (
endpoint,api_key) served inHello - Session lifecycle (
OpenSession,CloseSession,Ping) - Basic query execution (
Execute) ListDatabasesandSchema- Fallback
UnsupportedMethodfor unimplemented requests
Build
From this directory:
cargo build
The binary will be generated at:
examples/custom_driver/target/debug/custom-driver
Run manually (quick smoke test)
RUST_LOG=info cargo run -- --socket my-test-driver.sock
You should see:
Custom driver listening on socket: my-test-driver.sock
Integrate with DBFlux
RPC services are created from the DBFlux UI.
- Build the example binary.
- Start DBFlux normally.
- Open
Settings → RPC Services. - Add a new service with these values:
Socket ID:my-test-driver.sockCommand: the absolute path toexamples/custom_driver/target/debug/custom-driverArgs:--socket my-test-driver.sock- Optional env:
RUST_LOG=info
- Save the service. DBFlux persists it in the internal SQLite-backed settings store.
- Open the connection manager. You should see a new driver entry using metadata served by this custom driver (
Mock Database). - Select it and fill the form fields:
Endpoint(required)API Key(optional)
- Save and connect.
Process ownership
- If DBFlux starts this service from
Settings → RPC Services, DBFlux tracks it and stops it on DBFlux shutdown. - If you start the service manually and leave both
commandandargsempty, DBFlux uses the running socket but does not own or stop that process.
Notes
- The service key used internally by DBFlux is
rpc:<socket_id>. - If
commandandargsare both omitted, DBFlux expects this service to already be running. - If
commandis omitted butargsis present, DBFlux launchesdbflux-driver-host, and yourargsmust include both--driverand--socketwith the same socket ID. - Use absolute paths for
commandwhile testing to avoid PATH issues.
Queries to try
SELECT * FROM mockdb
INSERT INTO users VALUES (1, 'Test')
UPDATE users SET name = 'Updated' WHERE id = 1
DELETE FROM users WHERE id = 1
Troubleshooting
- Driver does not appear in UI: check the Services settings panel and DBFlux logs for launch/probe diagnostics.
- Connection refused: ensure
socket_idmatches between config and--socketarg. - Permission denied: ensure the binary in
commandis executable. - Version mismatch: ensure example and DBFlux are built from compatible code.
- No form fields appear: verify your service returns
form_definitioninHello. - Service disappeared after app restart: re-open
Settings → RPC Servicesand confirm the saved service still points to the same binary/socket.