Feat/actix adapter - #15
Closed
crustyrustacean wants to merge 11 commits into
Closed
crustyrustacean wants to merge 11 commits into
crustyrustacean wants to merge 11 commits into
Conversation
- Sse type: real streaming via HttpResponse::streaming() - From<T> for Sse on all builders + DatastarEvent - ReadSignals<T> extractor (FromRequest) with tracing parity - header module ported from axum integration - 7 integration tests (write + read sides)
- actix-hello: typewriter effect, streaming loop (single event type) - actix-activity-feed: dashboard with auto-generate + manual events, path params, interleaved PatchElements/PatchSignals - register both examples in Cargo.toml - update README to list Actix Web integration
- actix-live-reload: dev-only live reload with cfg-gated /hotreload route, uses ExecuteScript + one-shot AtomicBool + infinite pending stream - actix-test-suite: conformance suite server on /test, reads TestCase events and streams back SSE (ExecuteScript/PatchElements/PatchSignals) - register both examples in Cargo.toml - fix str_to_string clippy lint in tests
- Single-event Sse doctest: .into() was ambiguous (E0283) with multiple framework features enabled, since PatchElements has From impls for DatastarEvent, Sse, axum, rocket and warp event types. Use Sse::from. - Streaming doctest: consts is not re-exported from the prelude (E0432); import it from datastar::consts. - Includes cargo fmt for the actix adapter, examples and tests (F1).
- Alphabetize [dev-dependencies] (actix-web, urlencoding were appended after warp, breaking the dependencies-are-sorted CI gate). - Apply cargo-sort canonical formatting: expand actix feature array to multi-line, add missing EOF newline (F4).
- README: list Actix Web and Warp among supported frameworks; fix typo. - Makefile: add hello/live-reload/activity-feed/test-suite actix run targets plus aligned usage help entries. - .gitignore: restore trailing newline.
Upstream v0.4.1 extracted the conformance test-case types into examples/sdk_test/mod.rs, shared by the axum, warp, and rocket test-suite examples. Adopt it here instead of carrying a private copy, which had drifted: it lacked the namespace and view_transition_selector fields added to PatchElements after Datastar 1.0.2.
Align ReadSignals with the adapter contract upstream settled in starfederation#12: GET and DELETE read signals from the datastar query parameter, every other method (including QUERY) from the JSON body. A missing datastar parameter now deserializes as null instead of returning 400, so ReadSignals<Option<T>> yields None on a plain page load. DatastarParam becomes Option<serde_json::Value> to match the other adapters. Adds tests for DELETE extraction and the optional-signals behavior.
Sse boxed its stream as `dyn Stream<Item = DatastarEvent>`, which is not Send, so a handler returning Sse would be rejected at runtime by actix-web's multi-threaded server. Actix workers require responders to be Send. Adds the + Send bound to the boxed stream and to Sse::new, and documents why. All actix examples already used Send streams via asynk_strim::stream_fn, so this is a source-compatible bound on the SDK's own type.
That bound was wrong. Actix-Web does not require responders or handler futures to be Send: it runs handlers on the worker thread rather than moving them across threads. Its own bounds are !Send throughout -- Handler::Future has no Send requirement, Responder has none, and HttpResponse::streaming takes S: Stream<..> + 'static. So the previous commit's premise (that actix would reject a non-Send responder at runtime) was false, and the + Send bound was an artificial restriction that would have rejected legitimate streams holding Rc or a !Send guard across an await. Restores the unconstrained bound and documents why it is correct. Adds tests/nonsend.rs covering a !Send (Rc<Cell<usize>>) stream end to end.
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.
No description provided.