Skip to content

Conversation

@Xuanwo
Copy link
Member

@Xuanwo Xuanwo commented Jan 4, 2026

Which issue does this PR close?

None

Rationale for this change

Add RouteLayer so that users can route requests based on path.

What changes are included in this PR?

We gonna build something to allow users to:

fn build_default() -> Result<Operator> {
    Operator::new(services::Memory::default())?.finish()
}

fn build_parquet_fast_path() -> Result<Operator> {
    Operator::new(services::Memory::default())?
        .layer(TimeoutLayer::default().with_timeout(Duration::from_secs(3)))
        .finish()
}

fn build_routed_operator() -> Result<Operator> {
    let default_op = build_default()?;
    let parquet_op = build_parquet_fast_path()?;

    let routed = default_op.layer(
        RouteLayer::builder()
            .route("**/*.parquet", parquet_op)
            .build()?,
    );

    Ok(routed)
}

Are there any user-facing changes?

AI Usage Statement

Parts of this PR were drafted with assistance from Codex (with gpt-5.2) and fully reviewed and edited by me. I take full responsibility for all changes.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jan 4, 2026
@Xuanwo Xuanwo changed the title RFC: Route Layer RFC-7130: Route Layer Jan 4, 2026
@Xuanwo Xuanwo mentioned this pull request Jan 4, 2026
Copy link
Contributor

@MrCroxx MrCroxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!This is a very good feature.

There’s one thing I’m not quite sure about: when specifying the purpose of a route in the fn route() method, is it better to use an Operator or an Accessor? Although the boundary between the two doesn’t seem very strict at the moment, using an Accessor might allow for more complex composition rules?

@Xuanwo
Copy link
Member Author

Xuanwo commented Jan 4, 2026

LGTM!This is a very good feature.

There’s one thing I’m not quite sure about: when specifying the purpose of a route in the fn route() method, is it better to use an Operator or an Accessor?

My current plan is to use Operator, as it is part of our stable public API. I also prefer to avoid letting users interact directly with Accessor.

Although the boundary between the two doesn’t seem very strict at the moment, using an Accessor might allow for more complex composition rules?

Ideally, the Operator is simply a wrapper around the Accessor. If users need to perform more complex operations, they can directly construct the Accessor and use Operator::new.

Copy link
Contributor

@flaneur2020 flaneur2020 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! lookin really nice

Copy link
Member

@koushiro koushiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 4, 2026
Copy link
Contributor

@meteorgan meteorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It's an interesting idea.

@Xuanwo Xuanwo merged commit 8817d47 into main Jan 6, 2026
57 checks passed
@Xuanwo Xuanwo deleted the xuanwo/route-layer branch January 6, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants