Skip to content

Commit 7d919af

Browse files
Jakub Konkakubkon
authored andcommitted
Handle budget in Task def
1 parent dd071b9 commit 7d919af

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/task.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub struct TaskBuilder<'a> {
5151
binary: GWasmBinary<'a>,
5252
name: Option<String>,
5353
bid: Option<f64>,
54+
budget: Option<f64>,
5455
timeout: Option<Timeout>,
5556
subtask_timeout: Option<Timeout>,
5657
input_dir_path: PathBuf,
@@ -66,6 +67,7 @@ impl<'a> TaskBuilder<'a> {
6667
binary,
6768
name: None,
6869
bid: None,
70+
budget: None,
6971
timeout: None,
7072
subtask_timeout: None,
7173
input_dir_path: workspace.as_ref().join("in"),
@@ -87,6 +89,12 @@ impl<'a> TaskBuilder<'a> {
8789
self
8890
}
8991

92+
/// Sets task's budget value
93+
pub fn budget(mut self, budget: f64) -> Self {
94+
self.budget = Some(budget);
95+
self
96+
}
97+
9098
/// Sets task's [`Timeout`](../timeout/struct.Timeout.html) value
9199
pub fn timeout(mut self, timeout: Timeout) -> Self {
92100
self.timeout = Some(timeout);
@@ -185,7 +193,14 @@ impl<'a> TaskBuilder<'a> {
185193
options.subtasks.insert(name, subtask);
186194
}
187195

188-
Ok(Task::new(name, bid, timeout, subtask_timeout, options))
196+
Ok(Task::new(
197+
name,
198+
bid,
199+
self.budget,
200+
timeout,
201+
subtask_timeout,
202+
options,
203+
))
189204
}
190205
}
191206

@@ -219,6 +234,8 @@ pub struct Task {
219234
task_type: String,
220235
name: String,
221236
bid: f64,
237+
#[serde(skip_serializing_if = "Option::is_none")]
238+
budget: Option<f64>,
222239
timeout: Timeout,
223240
subtask_timeout: Timeout,
224241
options: Options,
@@ -229,6 +246,7 @@ impl Task {
229246
pub fn new<S: Into<String>>(
230247
name: S,
231248
bid: f64,
249+
budget: Option<f64>,
232250
timeout: Timeout,
233251
subtask_timeout: Timeout,
234252
options: Options,
@@ -237,6 +255,7 @@ impl Task {
237255
task_type: "wasm".into(),
238256
name: name.into(),
239257
bid,
258+
budget,
240259
timeout,
241260
subtask_timeout,
242261
options,
@@ -253,6 +272,11 @@ impl Task {
253272
self.bid
254273
}
255274

275+
/// Task's budget value
276+
pub fn budget(&self) -> Option<f64> {
277+
self.budget
278+
}
279+
256280
/// Task's [`Timeout`](../timeout/struct.Timeout.html) value
257281
pub fn timeout(&self) -> &Timeout {
258282
&self.timeout

0 commit comments

Comments
 (0)