ecli_lib/runner/client/
mod.rs

1//!  SPDX-License-Identifier: MIT
2//!
3//! Copyright (c) 2023, eunomia-bpf
4//! All rights reserved.
5//!
6
7/// The HTTP client
8#[cfg(feature = "http-client")]
9pub mod http;
10/// The native client
11#[cfg(feature = "native-client")]
12pub mod native;
13
14use crate::{config::ProgramType, error::Result};
15
16use super::{LogEntry, ProgramHandle};
17
18/// Status of an exist program
19#[derive(Debug, Clone, PartialEq, Eq)]
20pub enum ProgramStatus {
21    Running,
22    Paused,
23}
24/// Description of an exist program
25#[derive(Debug, Clone)]
26pub struct ProgramDesc {
27    pub id: ProgramHandle,
28    pub name: String,
29    pub status: ProgramStatus,
30}
31/// Common interfaces for client
32#[async_trait::async_trait]
33pub trait AbstractClient {
34    async fn start_program(
35        &self,
36        name: Option<String>,
37        prog_buf: &[u8],
38        prog_type: ProgramType,
39        export_json: bool,
40        args: &[String],
41        btf_archive_path: Option<String>,
42    ) -> Result<ProgramHandle>;
43    async fn terminate_program(&self, handle: ProgramHandle) -> Result<()>;
44    async fn set_program_pause_state(&self, handle: ProgramHandle, pause: bool) -> Result<()>;
45    async fn fetch_logs(
46        &self,
47        handle: ProgramHandle,
48        cursor: Option<usize>,
49        maximum_count: Option<usize>,
50    ) -> Result<Vec<(usize, LogEntry)>>;
51    async fn get_program_list(&self) -> Result<Vec<ProgramDesc>>;
52}