1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. #![feature(const_fn_fn_ptr_basics)] //! 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 `dylib` is supported, and not `cdylib` or `staticlib`, because the latter two are //! > not able to use TiKV's allocator. See also the documentation in [`std::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 //! //! ```no_run //! 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()); //! ``` #[doc(hidden)] pub mod allocator; #[doc(hidden)] pub mod util; mod errors; mod plugin_api; mod storage_api; pub use errors::*; pub use plugin_api::*; pub use storage_api::*;