feat: expose ConnectionGuard as request extension#1443
feat: expose ConnectionGuard as request extension#1443niklasad1 merged 3 commits intoparitytech:masterfrom dinhani:master
Conversation
|
Thanks Can you just create a simple test for this? Similar to https://github.com/paritytech/jsonrpsee/blob/master/tests/tests/integration_tests.rs#L210-#L225 but you need to add an new handler that actually fetches the ConnGuard from the extension. |
| request.extensions_mut().insert::<ConnectionId>(conn.conn_id.into()); | ||
| let req_ext = request.extensions_mut(); | ||
| req_ext.insert::<ConnectionGuard>(conn_guard.clone()); | ||
| req_ext.insert::<ConnectionId>(conn.conn_id.into()); |
There was a problem hiding this comment.
Cool, we could probably merge the ConnectionID and ConnectionGuard as some point to another type e.g. ConnectionDetails or something
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn connection_guard_extension_with_different_ws_clients() { |
There was a problem hiding this comment.
it's sufficient with one client but this does hurt, thanks :)
|
@niklasad1 I tried to put the new test together with the one you pointed, but I think it would become too complex, so I created a new test and renamed the other one to make it clear which extension each one is testing. |
Yeah, you made the right call by creating another test. All good, just run |
|
that's nice the PR is already created <3 @niklasad1 could you suggest another reviewer with write access for this PR? |
Fixes #1438
Since ConnectionGuard keeps the internal information inside an Arc, it should be cheap to clone it for each request.