Expand description
§Tower Service Integration
Bridges Bob’s port traits with the tower::Service ecosystem, enabling
composition with standard middleware (timeout, retry, rate limit, etc.)
without reimplementing them in the framework.
§Design Philosophy
This module demonstrates extreme trait reuse by leveraging tower::Service
as the universal middleware abstraction instead of building custom middleware chains.
§Key Patterns
- Blanket implementations: Every
ToolPortautomatically becomes atower::Service - Extension traits: Fluent APIs for middleware composition
- Type-state builders: Compile-time validation of middleware chains
- Associated types: Bind request/response types to service definitions
§Example
ⓘ
use bob_runtime::tower_service::*;
use tower::ServiceBuilder;
use std::time::Duration;
// Wrap a ToolPort with tower middleware
let tool_service = ToolService::new(my_tool_port);
let guarded = ServiceBuilder::new()
.timeout(Duration::from_secs(15))
.rate_limit(10, Duration::from_secs(1))
.service(tool_service);Structs§
- LlmRequest
Wrapper - Request type for LLM completion services.
- LlmResponse
Wrapper - Response type for LLM completion services.
- LlmService
- A
tower::Servicewrapper aroundLlmPort::complete. - Tool
List Request - Request type for tool listing services.
- Tool
List Service - A
tower::Servicewrapper aroundToolPort::list_tools. - Tool
Request - Request type for tool execution services.
- Tool
Response - Response type for tool execution services.
- Tool
Service - A
tower::Servicewrapper aroundToolPort::call_tool.
Traits§
- LlmPort
Service Ext - Extension trait that converts an
LlmPortinto a tower service. - Service
Ext - Extension trait for ergonomic service composition.
- Tool
Port Service Ext - Extension trait that converts a
ToolPortinto tower services.