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

lazy middleware #1507

Merged
merged 27 commits into from Feb 20, 2018
Merged

lazy middleware #1507

merged 27 commits into from Feb 20, 2018

Conversation

tanner0101
Copy link
Member

@tanner0101 tanner0101 commented Feb 19, 2018

  • creates one set of middleware per event loop, preventing race conditions in middleware
  • losslessly optimizes DateMiddleware to only calculate a new RFC1123 timestamp every second
  • adds a new router.grouped(MiddlewareType.self) overload for creating a route group around a middleware type that will be lazily initialized (on the event loop) when requested.
router.grouped(DateMiddleware.self).get("datetest") { req in
    return HTTPStatus.ok
}

In the above snippet, DateMiddleware won't be initialized until the first time that route is hit. It will subsequently be initialized for each event loop, until all event loops have one cached.

  • adds application-wide timeout for requests taking longer than 30 seconds
[ ERROR ] Vapor.VaporError.timeout: The application timed out waiting for response. (Services+Default.swift:207)
[ DEBUG ] Suggested fixes for Vapor.VaporError.timeout: Inspect the route responsible for responding to GET /fcm (EngineServer.swift:198)

Resolves #1479.

@tanner0101 tanner0101 added the enhancement New feature or request label Feb 19, 2018
@tanner0101 tanner0101 self-assigned this Feb 19, 2018
@tanner0101 tanner0101 added this to Todo in Vapor 3 Feb 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants