lexe_api_core/models/runner.rs
1use lexe_common::{
2 api::{MegaId, user::UserPk},
3 time::TimestampMs,
4};
5use serde::{Deserialize, Serialize};
6
7use crate::types::{LeaseId, ports::RunPorts};
8
9/// A request sent to a meganode API server to run a usernode within a meganode.
10#[derive(Serialize, Deserialize)]
11pub struct MegaNodeApiUserRunRequest {
12 /// The user to run.
13 pub user_pk: UserPk,
14
15 /// The lease ID for this user node.
16 pub lease_id: LeaseId,
17
18 /// Included to sanity check that we've requested the right meganode.
19 pub mega_id: MegaId,
20
21 /// Whether the node should shut down after completing sync.
22 pub shutdown_after_sync: bool,
23}
24
25#[derive(Serialize, Deserialize)]
26pub struct MegaNodeApiUserRunResponse {
27 pub run_ports: RunPorts,
28}
29
30/// A request from a usernode to renew its lease.
31#[derive(Serialize, Deserialize)]
32pub struct UserLeaseRenewalRequest {
33 /// The ID of the lease to renew.
34 pub lease_id: LeaseId,
35 /// Sanity check: The requesting user.
36 pub user_pk: UserPk,
37 /// Sanity check: The current time within the enclave.
38 pub timestamp: TimestampMs,
39}
40
41/// A notification from a meganode that a user has shut down,
42/// and that we can terminate the user's lease.
43#[derive(Serialize, Deserialize)]
44pub struct UserFinishedRequest {
45 /// The user that shut down.
46 pub user_pk: UserPk,
47 /// The ID of the lease to terminate.
48 pub lease_id: LeaseId,
49 /// Sanity check: The meganode issuing the request.
50 pub mega_id: MegaId,
51}
52
53/// A request to evict a usernode within a meganode.
54#[derive(Serialize, Deserialize)]
55pub struct MegaNodeApiUserEvictRequest {
56 /// The user to be evicted.
57 pub user_pk: UserPk,
58 /// Sanity check: The meganode to which the request is being sent.
59 pub mega_id: MegaId,
60}