Skip to main content

Module plugin

Module plugin 

Source
Expand description

The plugin SDK: implement one of Source, Format or Destination and call the matching serve_* function from main. The SDK owns stdin/stdout, the handshake, framing, request ids, error replies and panics.

Formats and destinations declare their options (options()) and add any rule a declaration can’t express (validate()). The SDK checks a config block against both on validate and before every write and deliver, so plugin code only sees options that passed.

  • Logging: use the log crate (log::info!, log::warn!), or [log] for a message with fields; the SDK sends them to core as log messages. The plugin’s own records keep their level; its dependencies’ are shown only with -v. Long requests may report progress.
  • Errors: return a PluginError to give core the problem’s kind and code; any other error is sent as a plain message.
  • Cancellation: stdin is read on a background thread while a request runs. On cancel (or when core goes away) cancelled turns true and the hook set with on_cancel runs, e.g. to cancel a query on the server.

Structs§

About
Identity reported in the handshake.
Delivery
A destination deliver request.
DeliveryFile
One file to deliver: the local copy in target/run/ and its rendered remote path, if any.
Input
The frames core sends, read on a background thread (see [read_stdin]).
Loaded
The outcome of Source::load.
PluginError
An error with its kind and, optionally, a code. The SDK namespaces the code by the plugin (host-key-mismatch is sent as sftp/host-key-mismatch).
ResultSet
One incoming result set, streamed from core.
ResultSets
Hands a format plugin its result sets one at a time, in order.
WriteRequest
A format write request.

Enums§

ErrorKind
What kind of problem a PluginError is (the kinds of DRE’s error-code registry).
Plugin
One of the plugins a package’s executable serves (see serve_package).

Traits§

Destination
Format
ResultSink
Where a source pushes the outcome of execute: either no_result, or begin followed by any number of batch calls.
Source

Functions§

cancelled
Whether core has cancelled the request running now. Long loops check it between steps.
conn_bool
Read a flag that may be written as a boolean or a string.
conn_required
Read a required string field from a connection map.
conn_str
Read a string field from a connection map.
log
Send a log message to core.
log_fields
Send a log message to core, with structured fields (never secrets).
on_cancel
Run hook when core cancels a request, on the stdin reader’s thread, while the request is still running on the main one (e.g. ask the server to cancel the query). Replaces any hook set before. The request then fails, and the SDK replies with kind cancelled.
progress
Tell core how far a long request has got; it shows the latest.
serve_destination
serve_format
serve_package
Serve every plugin of a package from one executable. Core’s hello names the plugin it wants; without one, the first is served.
serve_source

Type Aliases§

Error
Result