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 3 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 {
return 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"")
}
}
8 changes: 8 additions & 0 deletions proxy_components/proxy_ffi/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,14 @@ pub mod root {
arg3: root::DB::BaseBuffView,
) -> root::DB::FileEncryptionInfoRaw,
>,
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,
>,
pub fn_handle_batch_read_index: ::std::option::Option<
unsafe extern "C" fn(
arg1: root::DB::RaftStoreProxyPtr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ impl RaftStoreProxyFFIHelper {
fn_handle_new_file: Some(ffi_handle_new_file),
fn_handle_delete_file: Some(ffi_handle_delete_file),
fn_handle_link_file: Some(ffi_handle_link_file),
fn_get_keyspace_encryption: Some(CloudStorageEngineFFI::ffi_get_keyspace_encryption),
Copy link
Member

@CalvinNeo CalvinNeo Jan 17, 2024

Choose a reason for hiding this comment

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

Could we also put these two ffis into one struct, like sst_reader_interfaces?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

fn_get_master_key: Some(CloudStorageEngineFFI::ffi_get_master_key),
fn_handle_batch_read_index: Some(ffi_batch_read_index),
sst_reader_interfaces: SSTReaderInterfaces {
fn_get_sst_reader: Some(ffi_make_sst_reader),
Expand Down
2 changes: 2 additions & 0 deletions raftstore-proxy/ffi/src/RaftStoreProxyFFI/ProxyFFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ struct RaftStoreProxyFFIHelper {
BaseBuffView);
FileEncryptionInfoRaw (*fn_handle_link_file)(RaftStoreProxyPtr, BaseBuffView,
BaseBuffView);
bool (*fn_get_keyspace_encryption)(RaftStoreProxyPtr, uint32_t);
RawCppStringPtr (*fn_get_master_key)(RaftStoreProxyPtr);
void (*fn_handle_batch_read_index)(
RaftStoreProxyPtr, CppStrVecView, RawVoidPtr, uint64_t,
void (*fn_insert_batch_read_index_resp)(RawVoidPtr, BaseBuffView,
Expand Down
Loading