Skip to content

Commit 23baffc

Browse files
FFI: add two empty implement FFI for compatibility (#361)
* FFI: add two empty implement FFI Signed-off-by: Lloyd-Pottiger <[email protected]> * add description Signed-off-by: Lloyd-Pottiger <[email protected]> * move into a struct Signed-off-by: Lloyd-Pottiger <[email protected]> * move to CloudStorageEngineInterfaces Signed-off-by: Lloyd-Pottiger <[email protected]> * fmt Signed-off-by: Lloyd-Pottiger <[email protected]> * update version Signed-off-by: Lloyd-Pottiger <[email protected]> * f Signed-off-by: Lloyd-Pottiger <[email protected]> * f Signed-off-by: Lloyd-Pottiger <[email protected]> * update version Signed-off-by: Lloyd-Pottiger <[email protected]> --------- Signed-off-by: Lloyd-Pottiger <[email protected]>
1 parent 04e2be4 commit 23baffc

File tree

5 files changed

+49
-5
lines changed

5 files changed

+49
-5
lines changed

proxy_components/proxy_ffi/src/encryption_impls.rs

+19
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,22 @@ pub extern "C" fn ffi_handle_link_file(
166166
)
167167
}
168168
}
169+
170+
// The CloudStorageEngineFFI contains dummy implementation of
171+
// CloudStorageEngine-specific FFI, not used, just for tiflash compilation.
172+
pub struct CloudStorageEngineFFI {}
173+
174+
impl CloudStorageEngineFFI {
175+
// always return false
176+
pub extern "C" fn ffi_get_keyspace_encryption(
177+
_proxy_ptr: RaftStoreProxyPtr,
178+
_keyspace_id: u32,
179+
) -> bool {
180+
false
181+
}
182+
183+
// always return empty string
184+
pub extern "C" fn ffi_get_master_key(_proxy_ptr: RaftStoreProxyPtr) -> RawCppStringPtr {
185+
get_engine_store_server_helper().gen_cpp_string(b"")
186+
}
187+
}

proxy_components/proxy_ffi/src/interfaces.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,18 @@ pub mod root {
311311
) -> root::DB::RustStrWithViewVec,
312312
>,
313313
}
314+
#[repr(C)]
315+
#[derive(Debug)]
316+
pub struct CloudStorageEngineInterfaces {
317+
pub fn_get_keyspace_encryption: ::std::option::Option<
318+
unsafe extern "C" fn(arg1: root::DB::RaftStoreProxyPtr, arg2: u32) -> bool,
319+
>,
320+
pub fn_get_master_key: ::std::option::Option<
321+
unsafe extern "C" fn(
322+
arg1: root::DB::RaftStoreProxyPtr,
323+
) -> root::DB::RawCppStringPtr,
324+
>,
325+
}
314326
#[repr(u32)]
315327
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
316328
pub enum MsgPBType {
@@ -420,6 +432,7 @@ pub mod root {
420432
),
421433
>,
422434
pub sst_reader_interfaces: root::DB::SSTReaderInterfaces,
435+
pub cloud_storage_engine_interfaces: root::DB::CloudStorageEngineInterfaces,
423436
pub fn_server_info: ::std::option::Option<
424437
unsafe extern "C" fn(
425438
arg1: root::DB::RaftStoreProxyPtr,
@@ -741,7 +754,7 @@ pub mod root {
741754
arg3: root::DB::RawVoidPtr,
742755
) -> u32;
743756
}
744-
pub const RAFT_STORE_PROXY_VERSION: u64 = 5455550920944837743;
757+
pub const RAFT_STORE_PROXY_VERSION: u64 = 3560036848329077111;
745758
pub const RAFT_STORE_PROXY_MAGIC_NUMBER: u32 = 324508639;
746759
}
747760
}

proxy_components/proxy_ffi/src/raftstore_proxy_helper_impls.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use super::{
2020
encryption_impls::*,
2121
engine_store_helper_impls::*,
2222
interfaces_ffi::{
23-
BaseBuffView, ConfigJsonType, CppStrVecView, KVGetStatus, RaftProxyStatus,
24-
RaftStoreProxyFFIHelper, RaftStoreProxyPtr, RaftstoreVer, RawCppPtr, RawCppStringPtr,
25-
RawRustPtr, RawVoidPtr, RustStrWithView, SSTReaderInterfaces,
23+
BaseBuffView, CloudStorageEngineInterfaces, ConfigJsonType, CppStrVecView, KVGetStatus,
24+
RaftProxyStatus, RaftStoreProxyFFIHelper, RaftStoreProxyPtr, RaftstoreVer, RawCppPtr,
25+
RawCppStringPtr, RawRustPtr, RawVoidPtr, RustStrWithView, SSTReaderInterfaces,
2626
},
2727
read_index_helper,
2828
snapshot_reader_impls::*,
@@ -78,6 +78,12 @@ impl RaftStoreProxyFFIHelper {
7878
fn_approx_size: Some(ffi_approx_size),
7979
fn_get_split_keys: Some(ffi_get_split_keys),
8080
},
81+
cloud_storage_engine_interfaces: CloudStorageEngineInterfaces {
82+
fn_get_keyspace_encryption: Some(
83+
CloudStorageEngineFFI::ffi_get_keyspace_encryption,
84+
),
85+
fn_get_master_key: Some(CloudStorageEngineFFI::ffi_get_master_key),
86+
},
8187
fn_server_info: None,
8288
fn_make_read_index_task: Some(ffi_make_read_index_task),
8389
fn_make_async_waker: Some(ffi_make_async_waker),
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#pragma once
22
#include <cstdint>
3-
namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 5455550920944837743ull; }
3+
namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 3560036848329077111ull; }

raftstore-proxy/ffi/src/RaftStoreProxyFFI/ProxyFFI.h

+6
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ struct SSTReaderInterfaces {
206206
RustStrWithViewVec (*fn_get_split_keys)(SSTReaderPtr, uint64_t splits_count);
207207
};
208208

209+
struct CloudStorageEngineInterfaces {
210+
bool (*fn_get_keyspace_encryption)(RaftStoreProxyPtr, uint32_t);
211+
RawCppStringPtr (*fn_get_master_key)(RaftStoreProxyPtr);
212+
};
213+
209214
enum class MsgPBType : uint32_t {
210215
ReadIndexResponse = 0,
211216
ServerInfoResponse,
@@ -264,6 +269,7 @@ struct RaftStoreProxyFFIHelper {
264269
void (*fn_insert_batch_read_index_resp)(RawVoidPtr, BaseBuffView,
265270
uint64_t)); // To remove
266271
SSTReaderInterfaces sst_reader_interfaces;
272+
CloudStorageEngineInterfaces cloud_storage_engine_interfaces;
267273

268274
uint32_t (*fn_server_info)(RaftStoreProxyPtr, BaseBuffView, RawVoidPtr);
269275
RawRustPtr (*fn_make_read_index_task)(RaftStoreProxyPtr, BaseBuffView);

0 commit comments

Comments
 (0)