Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial attempt to support rama in shuttle #1943

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

GlenDC
Copy link
Contributor

@GlenDC GlenDC commented Dec 30, 2024

Description of change

Initial support of rama https://ramaproxy.org/, using the latest alpha release 0.2.0-alpha.5.
First non-alpha release is expected Q1 2025, which will be 0.2.0.

Rama can be used as a transport-layer runtime or application-layer runtime.

Rama users can also terminate their TLS themselves, but dunno if shuttle allows that?
Not a blocker if not (yet) possible, but just something that would at least have to be documented
in the shuttle-rama README.

I also exposed the usual result public types, but similar to tower,
service types can become quite long due to the heavy use in nested generics.

As such probably I thought it would be easiest to just let them return impl ShuttleService as
that keeps it clean, while still keeping rust happy and type-checked.

How has this been tested? (if applicable)

Not yet, please advice me on how to proceed.

It's my first real code contribution to shuttle so do let me know.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Initial integration of the Rama framework into Shuttle, providing support for both transport-layer (TCP) and application-layer (HTTP) services using Rama's alpha release 0.2.0-alpha.4.

  • Method name typo in RamaService::trasnport() needs to be corrected to transport() in services/shuttle-rama/README.md
  • Missing error handling for .await call in services/shuttle-rama/src/lib.rs line 103 could lead to potential hangs
  • Documentation should clarify TLS termination capabilities and limitations within Shuttle's environment

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

5 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile

services/shuttle-rama/Cargo.toml Outdated Show resolved Hide resolved
services/shuttle-rama/README.md Outdated Show resolved Hide resolved
services/shuttle-rama/README.md Outdated Show resolved Hide resolved
services/shuttle-rama/src/lib.rs Show resolved Hide resolved
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

This update adds implementation details for the Rama service integration, including service trait implementations and type wrappers for both transport and application layers.

  • Added RamaService wrapper struct in services/shuttle-rama/src/lib.rs with state management and service implementations
  • Implemented shuttle_runtime::Service trait for both transport and application layer services
  • Added type aliases ShuttleRamaTransport and ShuttleRamaApplication for cleaner return types

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +53 to +57
stream
.write_all(resp.as_bytes())
.await
.expect("write to stream");

Copy link

Choose a reason for hiding this comment

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

logic: Using expect() here could cause panic in production. Consider proper error handling and propagation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's an example...

codegen/src/lib.rs Outdated Show resolved Hide resolved
services/shuttle-rama/Cargo.toml Outdated Show resolved Hide resolved
services/shuttle-rama/README.md Outdated Show resolved Hide resolved
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

This update adds example code and documentation for the Rama framework integration, demonstrating both Application and Transport service implementations.

  • Added comprehensive examples in services/shuttle-rama/README.md showing both HTTP and TCP service patterns
  • Updated version reference to Rama 0.2.0-alpha.5 in documentation and dependencies
  • Missing GitHub example link in codegen/src/lib.rs service documentation table

3 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -24,6 +24,7 @@ mod shuttle_main;
/// | `ShuttleActixWeb` | [shuttle-actix-web](https://crates.io/crates/shuttle-actix-web)| [actix-web](https://docs.rs/actix-web/4.3) | 4.3 | [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/actix-web/hello-world)|
/// | `ShuttleAxum` | [shuttle-axum](https://crates.io/crates/shuttle-axum) | [axum](https://docs.rs/axum/0.7) | 0.7 | [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/axum/hello-world) |
/// | `ShuttlePoem` | [shuttle-poem](https://crates.io/crates/shuttle-poem) | [poem](https://docs.rs/poem/2.0) | 2.0 | [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/poem/hello-world) |
/// | `ShuttleRama` | [shuttle-rama](https://crates.io/crates/shuttle-rama) | [rama](https://docs.rs/rama/0.2.0-alpha.5)
Copy link

Choose a reason for hiding this comment

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

style: Missing version and example columns that other services have in the table. Add version '0.2.0-alpha.5' and GitHub example link to maintain consistency.

Comment on lines +32 to +39
async fn hello_world(mut stream: impl net::stream::Socket + net::Stream + Unpin) -> Result<(), Infallible> {
println!(
"Incoming connection from: {}",
stream
.peer_addr()
.map(|a| a.to_string())
.unwrap_or_else(|_| "???".to_owned())
);
Copy link

Choose a reason for hiding this comment

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

style: consider using debug! macro instead of println for better logging control in production

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant