Crate coprocessor_plugin_api[−][src]
This crate contains some necessary types and traits for implementing a custom coprocessor plugin for TiKV.
Most notably, if you want to write a custom plugin, your plugin needs to implement the
CoprocessorPlugin trait. The plugin then needs to be compiled to a dylib.
Note: Only
dylibis supported, and notcdyliborstaticlib, because the latter two are not able to use TiKV’s allocator. See also the documentation instd::alloc.
In order to make your plugin callable, you need to declare a constructor with the
declare_plugin macro.
A plugin can interact with the underlying storage via the RawStorage trait.
Example
use coprocessor_plugin_api::*; use std::ops::Range; #[derive(Default)] struct MyPlugin; impl CoprocessorPlugin for MyPlugin { fn name(&self) -> &'static str { "my-plugin" } fn on_raw_coprocessor_request( &self, ranges: Vec<Range<Key>>, request: RawRequest, storage: &dyn RawStorage, ) -> Result<RawResponse, PluginError> { Ok(vec![]) } } declare_plugin!(MyPlugin::default());
Modules
| errors | |
| plugin_api | |
| storage_api |
Macros
| declare_plugin | Declare a plugin for the library so that it can be loaded by TiKV. |
Enums
| PluginError | Error returned by operations on [ |
Traits
| CoprocessorPlugin | A plugin that allows users to execute arbitrary code on TiKV nodes. |
| RawStorage | Storage access for coprocessor plugins. |
Type Definitions
| Key | A raw key in the storage. |
| KvPair | A pair of a raw key and its value. |
| PluginResult | Result returned by operations on [ |
| RawRequest | Raw bytes of the request payload from the client to the coprocessor. |
| RawResponse | The response from the coprocessor encoded as raw bytes that are sent back to the client. |
| Value | A raw value from the storage. |