Skip to content

Commit

Permalink
add gevulot client infrastructure for rescheduling tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
trusch committed Jan 8, 2025
1 parent 4aa00fe commit dbe6254
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,19 @@ impl MsgSudoFreezeAccountBuilder {
})
}
}

#[derive(Builder)]
pub struct MsgRescheduleTask {
pub creator: String,
pub task_id: String,
}

impl MsgRescheduleTaskBuilder {
pub fn into_message(&self) -> Result<gevulot::MsgRescheduleTask> {
let msg = self.build().map_err(|e| Error::EncodeError(e.to_string()))?;
Ok(gevulot::MsgRescheduleTask {
creator: msg.creator,
id: msg.task_id,
})
}
}
21 changes: 20 additions & 1 deletion src/task_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
proto::gevulot::gevulot::{
MsgAcceptTask, MsgAcceptTaskResponse, MsgCreateTask, MsgCreateTaskResponse, MsgDeclineTask,
MsgDeclineTaskResponse, MsgDeleteTask, MsgDeleteTaskResponse, MsgFinishTask,
MsgFinishTaskResponse,
MsgFinishTaskResponse, MsgRescheduleTask, MsgRescheduleTaskResponse,
},
};

Expand Down Expand Up @@ -191,4 +191,23 @@ impl TaskClient {
.await?;
Ok(resp)
}

/// Reschedules a task.
///
/// # Arguments
///
/// * `msg` - The message containing the task ID to reschedule.
///
/// # Returns
///
/// A Result containing the response or an error.
pub async fn reschedule(&mut self, msg: MsgRescheduleTask) -> Result<MsgRescheduleTaskResponse> {
let resp: MsgRescheduleTaskResponse = self
.base_client
.write()
.await
.send_msg_sync(msg, "")
.await?;
Ok(resp)
}
}

0 comments on commit dbe6254

Please sign in to comment.