slbotbm commented on code in PR #3102:
URL: https://github.com/apache/iggy/pull/3102#discussion_r3161634878
##########
foreign/cpp/src/client.rs:
##########
@@ -378,6 +479,98 @@ impl Client {
Ok(())
})
}
+
+ pub fn get_stats(&self) -> Result<ffi::Stats, String> {
+ RUNTIME.block_on(async {
+ let stats = self
+ .inner
+ .get_stats()
+ .await
+ .map_err(|error| format!("Could not get stats: {error}"))?;
+ Ok(ffi::Stats::from(stats))
+ })
+ }
+
+ pub fn get_me(&self) -> Result<ffi::ClientInfoDetails, String> {
+ RUNTIME.block_on(async {
+ let client = self
+ .inner
+ .get_me()
+ .await
+ .map_err(|error| format!("Could not get current client info:
{error}"))?;
+ Ok(ffi::ClientInfoDetails::from(client))
+ })
+ }
+
+ pub fn get_client(&self, client_id: u32) -> Result<ffi::ClientInfoDetails,
String> {
+ RUNTIME.block_on(async {
+ let client = self
+ .inner
+ .get_client(client_id)
+ .await
+ .map_err(|error| format!("Could not get client '{client_id}':
{error}"))?;
+ ffi::ClientInfoDetails::try_from(client)
+ .map_err(|error| format!("Could not get client '{client_id}':
{error}"))
+ })
+ }
+
+ pub fn get_clients(&self) -> Result<Vec<ffi::ClientInfo>, String> {
+ RUNTIME.block_on(async {
+ let clients = self
+ .inner
+ .get_clients()
+ .await
+ .map_err(|error| format!("Could not get clients: {error}"))?;
+ Ok(clients.into_iter().map(ffi::ClientInfo::from).collect())
+ })
+ }
+
+ pub fn ping(&self) -> Result<(), String> {
+ RUNTIME.block_on(async {
+ self.inner
+ .ping()
+ .await
+ .map_err(|error| format!("Could not ping server: {error}"))?;
+ Ok(())
+ })
+ }
+
+ pub fn heartbeat_interval(&self) -> u64 {
+ RUNTIME.block_on(async {
self.inner.heartbeat_interval().await.as_micros() })
+ }
+
+ pub fn snapshot(
+ &self,
+ snapshot_compression: String,
+ snapshot_types: Vec<String>,
+ ) -> Result<Vec<u8>, String> {
+ let rust_compression = match snapshot_compression.trim() {
+ "" => RustSnapshotCompression::default(),
+ value => RustSnapshotCompression::from_str(value).map_err(|error| {
+ format!("Could not capture snapshot: invalid compression
'{value}': {error}")
+ })?,
+ };
+ let rust_snapshot_types = snapshot_types
+ .into_iter()
+ .map(|snapshot_type| {
+
RustSystemSnapshotType::from_str(&snapshot_type).map_err(|error| {
+ format!(
+ "Could not capture snapshot: invalid snapshot type
'{}': {}",
+ snapshot_type, error
+ )
+ })
+ })
+ .collect::<Result<Vec<_>, _>>()?;
+
+ RUNTIME.block_on(async {
+ let snapshot = self
+ .inner
+ .snapshot(rust_compression, rust_snapshot_types)
+ .await
+ .map_err(|error| format!("Could not capture snapshot:
{error}"))?;
+ Ok(snapshot.0)
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]