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

An example of adding multiple middlewares. #581

Merged
merged 3 commits into from
Nov 29, 2021

Conversation

dvdplm
Copy link
Contributor

@dvdplm dvdplm commented Nov 29, 2021

No description provided.

@dvdplm dvdplm changed the title Add an example of adding multiple middlewares. An example of adding multiple middlewares. Nov 29, 2021
examples/multi-middleware.rs Show resolved Hide resolved
#[derive(Clone)]
struct ThreadWatcher;
impl middleware::Middleware for ThreadWatcher {
type Instant = isize;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can there be negative threads?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, well, like the subtraction of "end - start" can be negative (these are system threads, so anything can happen while the program executes).

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I guess better safe than sorry, and it's just an example

examples/Cargo.toml Outdated Show resolved Hide resolved
dvdplm and others added 2 commits November 29, 2021 15:21
Co-authored-by: Maciej Hirsz <1096222+maciejhirsz@users.noreply.github.com>
Co-authored-by: Maciej Hirsz <1096222+maciejhirsz@users.noreply.github.com>
@dvdplm dvdplm merged commit 012a6d8 into mh-metrics-middleware Nov 29, 2021
@dvdplm dvdplm deleted the dp-add-multi-middleware-example branch November 29, 2021 14:23
dvdplm added a commit that referenced this pull request Dec 1, 2021
* Squashed MethodSink

* Middleware WIP

* Passing all the information through

* Unnecessary `false`

* Apply suggestions from code review

Co-authored-by: David <dvdplm@gmail.com>

* Add a setter for middleware (#577)

* Fix try-build tests

* Add a middleware setter and an example

* Actually add the example

* Grumbles

* Use an atomic

* Set middleware with a constructor instead

* Resolve a todo

* Update ws-server/src/server.rs

Co-authored-by: Maciej Hirsz <1096222+maciejhirsz@users.noreply.github.com>

* Update ws-server/src/server.rs

Co-authored-by: Maciej Hirsz <1096222+maciejhirsz@users.noreply.github.com>

* Update ws-server/src/server.rs

Co-authored-by: Maciej Hirsz <1096222+maciejhirsz@users.noreply.github.com>

Co-authored-by: Maciej Hirsz <1096222+maciejhirsz@users.noreply.github.com>

* Middleware::on_response for batches

* Middleware in HTTP

* fmt

* Server builder for HTTP

* Use actual time in the example

* HTTP example

* Middleware to capture method not found calls

* An example of adding multiple middlewares. (#581)

* Add an example of adding multiple middlewares.

* Update examples/multi-middleware.rs

Co-authored-by: Maciej Hirsz <1096222+maciejhirsz@users.noreply.github.com>

* Update examples/Cargo.toml

Co-authored-by: Maciej Hirsz <1096222+maciejhirsz@users.noreply.github.com>

Co-authored-by: Maciej Hirsz <1096222+maciejhirsz@users.noreply.github.com>

* Move `Middleware` to jsonrpsee-types (#582)

* Move `Middleware` to jsonrpsee-types

* Move Middleware trait to jsonrpsee-types

* Add some docs.

* Link middleware to `with_middleware` methods in docs

* Doctests

* Doc comment fixed

* Clean up a TODO

* Switch back to `set_middleware`

* fmt

* Tests

* Add `on_connect` and `on_disconnect`

* Add note to future selves

Co-authored-by: David <dvdplm@gmail.com>
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.

2 participants