Repository navigation
refactor(macros): paths, parsing, and error handling - #66
Merged
Merged
Conversation
Port #[event], #[handle] and the EventHandler controller expansion to the copy using darling parsing and path markers. #[event] now derives Clone and Debug and rejects non-struct inputs; #[handle] returns a pin-annotated boxed future instead of a cast. Switch ControllerStruct to accessors and align the web/jobs expanders with them.
Port the SocketIo controller expansion and #[on] handler to the copy. The controller registers a setup fn that wires connection/message handlers from inventory and applies OnConnect interceptors; #[on] emits per-method register/call fns and a HandlerRegistrar entry. Event names are validated as non-empty. Reuse path markers and CMetaStack keys aligned with the other kinds.
Port the Grpc controller expansion and the GrpcError derive to the copy. The controller registers build/register fns, applies OnRequest interceptors and honors the grpc-reflection descriptor set; GrpcError parses grpc/grpc_error with darling, reuses the shared error helpers, and emits From<Self> for tonic::Status with per-code tracing defaults. Reuse path markers, adding Grpc-prefixed names to avoid clashing with the web OnRequest markers.
Gate the events/grpc/jobs/socketio/web modules and the GrpcError derive by their feature, and allow dead_code crate-wide for now (to be narrowed per item later). grpc-reflection now implies grpc. Each feature and the web+grpc combination compile clean under -D warnings.
Swap the old `sword-macros` for the feature-first rewrite: keyed attributes now use `darling`, generated code emits real paths via `path!` markers, `HttpError`/`GrpcError` share the error helpers, and the crate uses the short feature names (`web`, `socketio`, `grpc`, `jobs`, `events`) that all dependent crates now reference; the old `axum` dependency is gone. Wiring it into the workspace also fixed a few codegen bugs (unit structs, missing semicolons, `Arc::clone` borrows) and added the `tests/sword-events` end-to-end test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cleanup pass over
sword-macrosto make it easier to read and change:path!markers instead of hardcoded::sword::internal::...paths.darling; positional ones stay onsyn.HttpErrorandGrpcErrorshare the helpers inshared/errors.rs.web/,socketio/,grpc/,jobs/,events/) with short feature names, andaxumis no longer a dependency.Arc::cloneborrows) and added the
tests/sword-eventsend-to-end test.