pub struct SimpleRuntime { /* private fields */ }Expand description
简单运行时 - 管理多个智能体的协同运行(非 dora 版本)
Implementations§
Source§impl SimpleRuntime
impl SimpleRuntime
Sourcepub fn new() -> SimpleRuntime
pub fn new() -> SimpleRuntime
创建新的简单运行时
Sourcepub async fn register_agent(
&self,
metadata: AgentMetadata,
config: AgentConfig,
role: &str,
) -> Result<Receiver<AgentEvent>, Error>
pub async fn register_agent( &self, metadata: AgentMetadata, config: AgentConfig, role: &str, ) -> Result<Receiver<AgentEvent>, Error>
注册智能体
Sourcepub fn message_bus(&self) -> &Arc<SimpleMessageBus>
pub fn message_bus(&self) -> &Arc<SimpleMessageBus>
获取消息总线
Sourcepub async fn get_agents_by_role(&self, role: &str) -> Vec<String>
pub async fn get_agents_by_role(&self, role: &str) -> Vec<String>
获取指定角色的智能体列表
Sourcepub async fn send_to_agent(
&self,
target_id: &str,
event: AgentEvent,
) -> Result<(), Error>
pub async fn send_to_agent( &self, target_id: &str, event: AgentEvent, ) -> Result<(), Error>
发送消息给指定智能体
Sourcepub async fn publish_to_topic(
&self,
topic: &str,
event: AgentEvent,
) -> Result<(), Error>
pub async fn publish_to_topic( &self, topic: &str, event: AgentEvent, ) -> Result<(), Error>
发布到主题
Sourcepub async fn create_stream(
&self,
stream_id: &str,
stream_type: StreamType,
metadata: HashMap<String, String>,
) -> Result<(), Error>
pub async fn create_stream( &self, stream_id: &str, stream_type: StreamType, metadata: HashMap<String, String>, ) -> Result<(), Error>
创建流
Sourcepub async fn subscribe_stream(
&self,
agent_id: &str,
stream_id: &str,
) -> Result<(), Error>
pub async fn subscribe_stream( &self, agent_id: &str, stream_id: &str, ) -> Result<(), Error>
订阅流
Sourcepub async fn unsubscribe_stream(
&self,
agent_id: &str,
stream_id: &str,
) -> Result<(), Error>
pub async fn unsubscribe_stream( &self, agent_id: &str, stream_id: &str, ) -> Result<(), Error>
取消订阅流
Sourcepub async fn send_stream_message(
&self,
stream_id: &str,
message: Vec<u8>,
) -> Result<(), Error>
pub async fn send_stream_message( &self, stream_id: &str, message: Vec<u8>, ) -> Result<(), Error>
发送流消息
Sourcepub async fn get_stream_info(
&self,
stream_id: &str,
) -> Result<Option<StreamInfo>, Error>
pub async fn get_stream_info( &self, stream_id: &str, ) -> Result<Option<StreamInfo>, Error>
获取流信息
Trait Implementations§
Source§impl Default for SimpleRuntime
Available on non-crate feature dora only.
impl Default for SimpleRuntime
Available on non-crate feature
dora only.Source§fn default() -> SimpleRuntime
fn default() -> SimpleRuntime
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SimpleRuntime
impl !RefUnwindSafe for SimpleRuntime
impl Send for SimpleRuntime
impl Sync for SimpleRuntime
impl Unpin for SimpleRuntime
impl UnsafeUnpin for SimpleRuntime
impl !UnwindSafe for SimpleRuntime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Message for T
impl<T> Message for T
Source§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
Convert a BoxedMessage to this concrete type
Source§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
Convert this message to a BoxedMessage