Skip to content

Commit 94aabf1

Browse files
committed
feat(anda_engine_server): add extra_info
1 parent d0bd8f9 commit 94aabf1

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

anda_engine_server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "anda_engine_server"
33
description = "A http server to serve multiple Anda engines."
44
repository = "https://github.com/ldclabs/anda/tree/main/anda_engine_server"
55
publish = true
6-
version.workspace = true
6+
version = "0.9.9"
77
edition.workspace = true
88
keywords.workspace = true
99
categories.workspace = true

anda_engine_server/src/handler.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub struct AppState {
2626
pub(crate) engines: Arc<BTreeMap<Principal, Engine>>,
2727
pub(crate) default_engine: Principal,
2828
pub(crate) start_time_ms: u64,
29+
pub(crate) extra_info: Arc<BTreeMap<String, Json>>,
2930
}
3031

3132
/// GET /.well-known/information
@@ -49,6 +50,7 @@ pub async fn get_information(
4950
default_engine: app.default_engine,
5051
start_time_ms: app.start_time_ms,
5152
caller,
53+
extra_info: app.extra_info.as_ref().clone(),
5254
};
5355

5456
match Content::from(&headers) {

anda_engine_server/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anda_core::BoxError;
1+
use anda_core::{BoxError, Json};
22
use anda_engine::engine::Engine;
33
use axum::{Router, routing};
44
use candid::Principal;
@@ -25,6 +25,7 @@ pub struct ServerBuilder {
2525
engines: BTreeMap<Principal, Engine>,
2626
default_engine: Option<Principal>,
2727
middlewares: Vec<Arc<dyn HttpMiddleware>>,
28+
extra_info: BTreeMap<String, Json>,
2829
}
2930

3031
impl Default for ServerBuilder {
@@ -46,6 +47,7 @@ impl ServerBuilder {
4647
engines: BTreeMap::new(),
4748
default_engine: None,
4849
middlewares: Vec::new(),
50+
extra_info: BTreeMap::new(),
4951
}
5052
}
5153

@@ -69,6 +71,11 @@ impl ServerBuilder {
6971
self
7072
}
7173

74+
pub fn with_extra_info(mut self, extra_info: BTreeMap<String, Json>) -> Self {
75+
self.extra_info = extra_info;
76+
self
77+
}
78+
7279
pub fn with_engines(
7380
mut self,
7481
mut engines: BTreeMap<Principal, Engine>,
@@ -163,6 +170,7 @@ impl ServerBuilder {
163170
engines: Arc::new(self.engines),
164171
default_engine,
165172
start_time_ms: unix_ms(),
173+
extra_info: Arc::new(self.extra_info),
166174
};
167175

168176
// Build a router that is still "missing" an `AppState`.

anda_engine_server/src/types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
use anda_core::Json;
12
use anda_engine::engine::AgentInfo;
23
use candid::Principal;
34
use serde::{Deserialize, Serialize};
5+
use std::collections::BTreeMap;
46

57
#[derive(Clone, Debug, Deserialize, Serialize)]
68
pub struct AppInformation {
79
pub engines: Vec<AgentInfo>,
810
pub default_engine: Principal,
911
pub caller: Principal,
1012
pub start_time_ms: u64,
13+
pub extra_info: BTreeMap<String, Json>,
1114
}

0 commit comments

Comments
 (0)