Skip to content

Commit

Permalink
Refactor away the return val of setConfiguration
Browse files Browse the repository at this point in the history
Signed-off-by: Mr-Kanister <[email protected]>
  • Loading branch information
Mr-Kanister committed Dec 6, 2024
1 parent f69dbbb commit 0416cb3
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ interface Client {

suspend fun getConfiguration(): Configuration

suspend fun setConfiguration(configuration: Configuration): UInt
suspend fun setConfiguration(configuration: Configuration)

suspend fun getOdexFiles(pid: UInt): Flow<String>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ object RustClient : Client {
return configuration
}

override suspend fun setConfiguration(configuration: Configuration): UInt {
override suspend fun setConfiguration(configuration: Configuration) {
this.configuration = configuration

return 0u
}

override suspend fun initStream(): Flow<Event> = flow {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class RustClient(private val inner: uniffi.client.Client) : Client {

override suspend fun getConfiguration(): Configuration = inner.getConfiguration().into()

override suspend fun setConfiguration(configuration: Configuration): UInt =
override suspend fun setConfiguration(configuration: Configuration) =
inner.setConfiguration(configuration.into())

override suspend fun getOdexFiles(pid: UInt): Flow<String> =
Expand Down
4 changes: 2 additions & 2 deletions rust/backend/daemon/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Ziofa for ZiofaImpl {
async fn set_configuration(
&self,
request: Request<Configuration>,
) -> Result<Response<SetConfigurationResponse>, Status> {
) -> Result<Response<()>, Status> {
let config = request.into_inner();

// TODO: Implement function 'validate'
Expand All @@ -109,7 +109,7 @@ impl Ziofa for ZiofaImpl {
.update_from_config(ebpf_guard.deref_mut(), &config)
.map_err(EbpfErrorWrapper::from)?;

Ok(Response::new(SetConfigurationResponse { response_type: 0 }))
Ok(Response::new(()))
}

type InitStreamStream = Receiver<Result<Event, Status>>;
Expand Down
2 changes: 1 addition & 1 deletion rust/client/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl Client {
Ok(self.0.lock().await.get_configuration().await?)
}

pub async fn set_configuration(&self, configuration: Configuration) -> Result<u32> {
pub async fn set_configuration(&self, configuration: Configuration) -> Result<()> {
Ok(self.0.lock().await.set_configuration(configuration).await?)
}

Expand Down
10 changes: 3 additions & 7 deletions rust/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,9 @@ impl Client {
Ok(self.ziofa.get_configuration(()).await?.into_inner())
}

pub async fn set_configuration(&mut self, configuration: Configuration) -> Result<u32> {
Ok(self
.ziofa
.set_configuration(configuration)
.await?
.into_inner()
.response_type)
pub async fn set_configuration(&mut self, configuration: Configuration) -> Result<()> {
self.ziofa.set_configuration(configuration).await?;
Ok(())
}

pub async fn init_stream(&mut self) -> Result<impl Stream<Item = Result<Event>>> {
Expand Down
8 changes: 2 additions & 6 deletions rust/shared/proto/ziofa.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ service Ziofa {
rpc CheckServer(google.protobuf.Empty) returns (CheckServerResponse) {}
rpc ListProcesses(google.protobuf.Empty) returns (ProcessList) {}

rpc GetConfiguration(google.protobuf.Empty) returns (config.Configuration){}
rpc SetConfiguration(config.Configuration) returns (SetConfigurationResponse){}
rpc GetConfiguration(google.protobuf.Empty) returns (config.Configuration) {}
rpc SetConfiguration(config.Configuration) returns (google.protobuf.Empty) {}

rpc InitStream(google.protobuf.Empty) returns (stream Event) {} // all Responses genereated by the ebpf-programms are send via this stream

Expand Down Expand Up @@ -64,10 +64,6 @@ message CmdlineData {
repeated string args = 1;
}

message SetConfigurationResponse{
uint32 response_type = 1;
}

message Event {
oneof event_data {
VfsWriteEvent vfs_write = 1;
Expand Down

0 comments on commit 0416cb3

Please sign in to comment.