MCPcopy Index your code
hub / github.com/cloudwego/motore

github.com/cloudwego/motore @motore-macros-0.4.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release motore-macros-0.4.3 ↗ · + Follow
103 symbols 159 edges 23 files 21 documented · 20% updated 20d agomotore-macros-0.4.3 · 2025-05-06★ 2742 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Motore

Crates.io Documentation License Build Status

Motore is an async middleware abstraction powered by AFIT and RPITIT.

Around Motore, we build modular and reusable components for building robust networking clients and servers.

Motore is greatly inspired by Tower.

Overview

Motore uses AFIT and RPITIT to reduce the mental burden of writing asynchronous code, especially to avoid the overhead of Box to make people less anxious.

The core abstraciton of Motore is the Service trait:

pub trait Service<Cx, Request> {
    /// Responses given by the service.
    type Response;
    /// Errors produced by the service.
    type Error;

    /// Process the request and return the response asynchronously.
    async fn call(&self, cx: &mut Cx, req: Request) -> Result<Self::Response, Self::Error>;
}

Getting Started

Combing AFIT and RPITIT together, we can write asynchronous code in a very concise and readable way.

pub struct Timeout<S> {
    inner: S,
    duration: Duration,
}

impl<Cx, Req, S> Service<Cx, Req> for Timeout<S>
where
    Req: 'static + Send,
    S: Service<Cx, Req> + 'static + Send + Sync,
    Cx: 'static + Send,
    S::Error: Send + Sync + Into<BoxError>,
{
    type Response = S::Response;

    type Error = BoxError;

    async fn call(&self, cx: &mut Cx, req: Req) -> Result<Self::Response, Self::Error> {
        let sleep = tokio::time::sleep(self.duration);
        tokio::select! {
            r = self.inner.call(cx, req) => {
                r.map_err(Into::into)
            },
            _ = sleep => Err(std::io::Error::new(std::io::ErrorKind::TimedOut, "service time out").into()),
        }
    }
}

We also provided the #[motore::service] macro to make writing a Serivce more async-native:

use motore::service;

pub struct S<I> {
    inner: I,
}

#[service]
impl<Cx, Req, I> Service<Cx, Req> for S<I>
where
   Req: Send + 'static,
   I: Service<Cx, Req> + Send + 'static + Sync,
   Cx: Send + 'static,
{
    async fn call(&self, cx: &mut Cx, req: Req) -> Result<I::Response, I::Error> {
        self.inner.call(cx, req).await
    }
}

FAQ

Where's the poll_ready(a.k.a. backpressure)?

https://www.cloudwego.io/docs/volo/faq/#where-did-poll_ready-backpressure-go

License

Motore is dual-licensed under the MIT license and the Apache License (Version 2.0).

See LICENSE-MIT and LICENSE-APACHE for details.

Credits

We have used some third party components, and we thank them for their work.

For the full list, you may refer to the CREDITS.md file.

Community

Motore user group

Extension points exported contracts — how you extend this code

Service (Interface)
An asynchronous function from a `Request` to a `Response`. The `Service` trait is a simplified interface making it easy [9 …
motore/src/service/mod.rs
Layer (Interface)
Decorates a [`Service`], transforming either the request or the response. Often, many of the pieces needed for writing [10 …
motore/src/layer/mod.rs
MakeConnection (Interface)
This trait is used to create a connection. The connection can either be a real connection or a virtual connection, whic [1 …
motore/src/make/make_connection.rs
Callback (Interface)
[`Service`] for binding lifetime to return value while using closure. This is just a temporary workaround for lifetime i [1 …
motore/src/service/service_fn.rs
ServiceExt (Interface)
An extension trait for `Service`s that provides a variety of convenient adapters [1 implementers]
motore/src/service/ext/mod.rs

Core symbols most depended-on inside this repo

clone
called by 8
motore/src/service/tower_adapter.rs
clone
called by 7
motore/src/service/mod.rs
layer
called by 5
motore/src/builder.rs
push
called by 3
motore/src/layer/layers.rs
service_fn
called by 2
motore/src/service/service_fn.rs
call
called by 2
motore/src/service/mod.rs
map_err
called by 2
motore/src/service/ext/mod.rs
layer_fn
called by 2
motore/src/layer/layer_fn.rs

Shape

Method 57
Class 23
Function 12
Interface 10
Enum 1

Languages

Rust100%

Modules by API surface

motore/src/service/mod.rs14 symbols
motore/src/builder.rs12 symbols
motore/src/service/tower_adapter.rs11 symbols
motore/src/service/service_fn.rs8 symbols
motore/src/layer/tower_adapter.rs6 symbols
motore/src/layer/layers.rs6 symbols
motore/src/layer/layer_fn.rs6 symbols
motore/src/timeout.rs5 symbols
motore/src/lib.rs5 symbols
motore/src/layer/stack.rs4 symbols
motore/src/layer/identity.rs4 symbols
motore/src/utils/either.rs3 symbols

For agents

$ claude mcp add motore \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page