This repository has been archived by the owner on Jan 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Make Rocket an implementation detail of Nemesis #97
Merged
Conversation
This file contains 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
Begin to hide Rocket implementation from consumers of nemesis. nemesis::server::Request provides a default implementation to generate Rack environment hashes and requires implementations to supply the Rack values. Rocket is an implementation detail of nemesis and the backend may change in the future, e.g. to Hyper.
Kill all of the dead code in foolsgold. This commit drops support for a shared interpreter.
The handler matches all paths at the mount point and responds to all HTTP methods.
The server implementation lives entirely in nemesis now
The only exported bits are Error, Builder, Mount.
lopopolo
commented
Jun 5, 2019
This was referenced Jun 6, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This PR builds upon what I learned in rwf2/Rocket#1019 and pulls the Rocket dependency inside
nemesis
crate.Rocket is an implementation detail of using
nemesis
to serve a Rack app. This PR creates an interface on top of Rocket to abstract over the server implementation if I want to later switch to e.g. a Hyper backend.The public interface to
nemesis
is aBuilder
struct that is used to configure routes for serving static assets and mounting Rack apps at a base path:ContentType
detection.RackApp
wraps aValue
andMrb
where theValue
is a Ruby object that responds to#call(env)
.RackApp
implementsValueLike
and exposes a typed interface around#call(env)
that returns a nemesisResponse
.Mount
contains the information necessary to serve aRackApp
at a prefix. It contains the base path mount point, aFn
that returns an interpreter and aFn
that returns aRackApp
given an interpreter.To handle a generic Rack application that responds to all paths and all HTTP methods, I introduce a
RackHandler
custom Rocket handler that generates all of the routes. TheRackHandler
contains a cloneable reference to theMount
.Currently, nemesis only supports the shared nothing exec mode where there is a new single use interpreter created per request. In a followup PR I would like to add support for per-worker-per-app interpreters.
This PR significantly refactors the error handling in
nemesis
crate. I found I was repeating myself a lot by introducing newError
types in each module and wrapping them and addingFrom
implementations. Instead, there is a globalError
type in thenemesis
crate root that implements all errors for all components innemesis
.foolsgold
crate is now fully implemented in terms ofnemesis
and has no direct dependency on Rocket.