ceylon_core/workspace/
agent.rs

1/*
2 * Copyright 2024-Present, Syigen Ltd. and Syigen Private Limited. All rights reserved.
3 * Licensed under the Apache License, Version 2.0 (See LICENSE or http://www.apache.org/licenses/LICENSE-2.0).
4 *
5 */
6
7use std::fmt::Debug;
8
9use serde::{Deserialize, Serialize};
10
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct AgentDetail {
13    pub name: String,
14    pub id: String,
15    pub role: String,
16}
17
18#[async_trait::async_trait]
19pub trait AgentBase {
20    async fn run_(&self, inputs: Vec<u8>);
21}
22
23#[async_trait::async_trait]
24pub trait MessageHandler: Send + Sync + Debug {
25    async fn on_message(&self, agent_id: String, data: Vec<u8>, time: u64);
26}
27
28#[async_trait::async_trait]
29pub trait Processor: Send + Sync + Debug {
30    async fn run(&self, input: Vec<u8>) -> ();
31}
32
33#[async_trait::async_trait]
34pub trait EventHandler: Send + Sync + Debug {
35    async fn on_agent_connected(&self, topic: String, agent: AgentDetail) -> ();
36}
37
38pub static ENV_WORKSPACE_ID: &str = "WORKSPACE_ID";
39pub static ENV_WORKSPACE_PEER: &str = "WORKSPACE_PEER";
40pub static ENV_WORKSPACE_PORT: &str = "WORKSPACE_PORT";
41pub static ENV_WORKSPACE_IP: &str = "WORKSPACE_IP";