Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFI: add two empty implement FFI for compatibility #361

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions proxy_components/proxy_ffi/src/encryption_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,22 @@ pub extern "C" fn ffi_handle_link_file(
)
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compatibility for whom?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// The CloudStorageEngineFFI contains dummy implementation of
// CloudStorageEngine-specific FFI, not used, just for tiflash compilation.
pub struct CloudStorageEngineFFI {}

impl CloudStorageEngineFFI {
// always return false
pub extern "C" fn ffi_get_keyspace_encryption(
_proxy_ptr: RaftStoreProxyPtr,
_keyspace_id: u32,
) -> bool {
false
}

// always return empty string
pub extern "C" fn ffi_get_master_key(_proxy_ptr: RaftStoreProxyPtr) -> RawCppStringPtr {
get_engine_store_server_helper().gen_cpp_string(b"")
}
}
15 changes: 14 additions & 1 deletion proxy_components/proxy_ffi/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ pub mod root {
) -> root::DB::RustStrWithViewVec,
>,
}
#[repr(C)]
#[derive(Debug)]
pub struct CloudStorageEngineInterfaces {
pub fn_get_keyspace_encryption: ::std::option::Option<
unsafe extern "C" fn(arg1: root::DB::RaftStoreProxyPtr, arg2: u32) -> bool,
>,
pub fn_get_master_key: ::std::option::Option<
unsafe extern "C" fn(
arg1: root::DB::RaftStoreProxyPtr,
) -> root::DB::RawCppStringPtr,
>,
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum MsgPBType {
Expand Down Expand Up @@ -420,6 +432,7 @@ pub mod root {
),
>,
pub sst_reader_interfaces: root::DB::SSTReaderInterfaces,
pub cloud_storage_engine_interfaces: root::DB::CloudStorageEngineInterfaces,
pub fn_server_info: ::std::option::Option<
unsafe extern "C" fn(
arg1: root::DB::RaftStoreProxyPtr,
Expand Down Expand Up @@ -734,7 +747,7 @@ pub mod root {
arg3: root::DB::RawVoidPtr,
) -> u32;
}
pub const RAFT_STORE_PROXY_VERSION: u64 = 14498963167462351742;
pub const RAFT_STORE_PROXY_VERSION: u64 = 15262247402413224460;
pub const RAFT_STORE_PROXY_MAGIC_NUMBER: u32 = 324508639;
}
}
12 changes: 9 additions & 3 deletions proxy_components/proxy_ffi/src/raftstore_proxy_helper_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use super::{
encryption_impls::*,
engine_store_helper_impls::*,
interfaces_ffi::{
BaseBuffView, ConfigJsonType, CppStrVecView, KVGetStatus, RaftProxyStatus,
RaftStoreProxyFFIHelper, RaftStoreProxyPtr, RaftstoreVer, RawCppPtr, RawCppStringPtr,
RawRustPtr, RawVoidPtr, RustStrWithView, SSTReaderInterfaces,
BaseBuffView, CloudStorageEngineInterfaces, ConfigJsonType, CppStrVecView, KVGetStatus,
RaftProxyStatus, RaftStoreProxyFFIHelper, RaftStoreProxyPtr, RaftstoreVer, RawCppPtr,
RawCppStringPtr, RawRustPtr, RawVoidPtr, RustStrWithView, SSTReaderInterfaces,
},
read_index_helper,
snapshot_reader_impls::*,
Expand Down Expand Up @@ -78,6 +78,12 @@ impl RaftStoreProxyFFIHelper {
fn_approx_size: Some(ffi_approx_size),
fn_get_split_keys: Some(ffi_get_split_keys),
},
cloud_storage_engine_interfaces: CloudStorageEngineInterfaces {
fn_get_keyspace_encryption: Some(
CloudStorageEngineFFI::ffi_get_keyspace_encryption,
),
fn_get_master_key: Some(CloudStorageEngineFFI::ffi_get_master_key),
},
fn_server_info: None,
fn_make_read_index_task: Some(ffi_make_read_index_task),
fn_make_async_waker: Some(ffi_make_async_waker),
Expand Down
2 changes: 1 addition & 1 deletion raftstore-proxy/ffi/src/RaftStoreProxyFFI/@version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once
#include <cstdint>
namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 14498963167462351742ull; }
namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 15262247402413224460ull; }
6 changes: 6 additions & 0 deletions raftstore-proxy/ffi/src/RaftStoreProxyFFI/ProxyFFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ struct SSTReaderInterfaces {
RustStrWithViewVec (*fn_get_split_keys)(SSTReaderPtr, uint64_t splits_count);
};

struct CloudStorageEngineInterfaces {
bool (*fn_get_keyspace_encryption)(RaftStoreProxyPtr, uint32_t);
RawCppStringPtr (*fn_get_master_key)(RaftStoreProxyPtr);
};

enum class MsgPBType : uint32_t {
ReadIndexResponse = 0,
ServerInfoResponse,
Expand Down Expand Up @@ -264,6 +269,7 @@ struct RaftStoreProxyFFIHelper {
void (*fn_insert_batch_read_index_resp)(RawVoidPtr, BaseBuffView,
uint64_t)); // To remove
SSTReaderInterfaces sst_reader_interfaces;
CloudStorageEngineInterfaces cloud_storage_engine_interfaces;

uint32_t (*fn_server_info)(RaftStoreProxyPtr, BaseBuffView, RawVoidPtr);
RawRustPtr (*fn_make_read_index_task)(RaftStoreProxyPtr, BaseBuffView);
Expand Down
Loading