1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! Glambda task definition.
//!
//!

use super::{ComputeOn, TaskDef, TaskDefOptions};
use serde::{Deserialize, Serialize};
use std::time::Duration;

type GLambdaTaskDef = TaskDef<GLambdaOptions>;

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GLambdaOptions {
    pub method: String,
    pub args: String,
    pub verification: String,
    pub outputs: Vec<String>,
}

impl TaskDefOptions for GLambdaOptions {
    const TASK_TYPE: &'static str = "GLambda";
}

#[derive(Serialize, Deserialize, Debug)]
pub struct GLambdaVerification {
    #[serde(rename = "type")]
    verification_type: GLambdaVerificationType,
}

#[derive(Serialize, Deserialize, Debug)]
pub enum GLambdaVerificationType {
    #[serde(rename = "None")]
    NoVerification,
    #[serde(rename = "External")]
    ExternallyVerified,
}

pub fn template() -> GLambdaTaskDef {
    TaskDef {
        task_type: GLambdaOptions::TASK_TYPE.to_string(),
        compute_on: ComputeOn::CPU,
        name: "simple glambda".to_string(),
        timeout: Duration::from_secs(600),
        subtask_timeout: Duration::from_secs(400),
        subtasks_count: 1,
        bid: 0.1,
        resources: vec![],
        concent_enabled: false,
        options: GLambdaOptions {
            method: "".to_string(),
            args: "".to_string(),
            verification: "".to_string(),
            outputs: vec![],
        },
    }
}