linera_base/task_processor.rs
1// Copyright (c) Facebook, Inc. and its affiliates.
2// Copyright (c) Zefchain Labs, Inc.
3// SPDX-License-Identifier: Apache-2.0
4
5//! Types related to the task processor features in the node service.
6
7use async_graphql::scalar;
8use serde::{Deserialize, Serialize};
9
10use crate::data_types::Timestamp;
11
12/// The off-chain actions requested by the service of an on-chain application.
13///
14/// On-chain applications should be ready to respond to GraphQL queries of the form:
15/// ```ignore
16/// query {
17/// nextActions(lastRequestedCallback: Timestamp, now: Timestamp!): ProcessorActions!
18/// }
19///
20/// query {
21/// processTaskOutcome(outcome: TaskOutcome!)
22/// }
23/// ```
24#[derive(Default, Debug, Serialize, Deserialize)]
25pub struct ProcessorActions {
26 /// The application is requesting to be called back no later than the given timestamp.
27 pub request_callback: Option<Timestamp>,
28 /// The application is requesting the execution of the given tasks.
29 pub execute_tasks: Vec<Task>,
30}
31
32scalar!(ProcessorActions);
33
34/// An off-chain task requested by an on-chain application.
35#[derive(Debug, Serialize, Deserialize)]
36pub struct Task {
37 /// The operator handling the task.
38 pub operator: String,
39 /// The input argument in JSON.
40 pub input: String,
41}
42
43/// The result of executing an off-chain operator.
44#[derive(Debug, Serialize, Deserialize)]
45pub struct TaskOutcome {
46 /// The operator handling the task.
47 pub operator: String,
48 /// The JSON output.
49 pub output: String,
50}
51
52scalar!(TaskOutcome);