Skip to content

Conversation

@google-labs-jules
Copy link

This change refactors the core traits EventHandler and Transport to improve performance and code quality. Specifically, EventHandler::on_event now takes an owned String for the event body, allowing for more flexible ownership transfer. The Transport trait now accepts headers as a slice of tuples &[(&str, &str)], replacing the previous (Vec, Vec) structure, which reduces allocations and simplifies usage. Additionally, error logging was added to the runtime loop, and several Clippy warnings were resolved.


PR created automatically by Jules for task 13206239033381123805 started by @guyo13

… ergonomics

- Updated `EventHandler::on_event` to take `event: String` (owned) instead of `&str`. This allows handlers to consume the event string without cloning if necessary.
- Updated `Transport` trait methods (`get`, `post`) to accept headers as `Option<&[(&str, &str)]>` instead of `Option<(Vec<&str>, Vec<&str>)>`. This avoids unnecessary vector allocations and enforces key-value pairing.
- Updated `ureq` backend implementation to support the new `Transport` interface.
- Updated `DefaultRuntime` to use the new trait definitions and handle headers more efficiently.
- Added error logging to the runtime loop for failed invocation fetches.
- Addressed Clippy warnings in `src/api/handler.rs` (doc comment), `src/api/response.rs` (range matching), and `src/backends/ureq.rs` (error handling).
- Updated `examples/echo-server.rs` to reflect the `EventHandler` trait change.
@google-labs-jules
Copy link
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

New to Jules? Learn more at jules.google/docs.

…gonomics

- Added unit tests for `EventContext` in `src/data/tests.rs` covering environment variable parsing.
- Added unit tests for `DefaultRuntime` in `src/runtime/tests.rs` using a `MockTransport` to verify runtime behavior without network calls.
- Refactored `Transport` trait to accept headers as `Option<&[(&str, &str)]>` for better ergonomics and performance.
- Refactored `EventHandler` trait to take `event: String` (owned) to allow flexible ownership transfer.
- Updated `ureq` backend and `examples/echo-server.rs` to match API changes.
- Added `serial_test` dependency to ensure thread safety for tests modifying environment variables.
- Improved error logging in the runtime loop.
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