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.
Summary
This draft PR demonstrates styx codebase when the old, monolithic application router code has been removed. The second part of this PR demonstrates the programmatic API for injecting configuration objects into Styx Core.
Part 1: Remove Application Router
Removal of the old application router reduces styx codebase about 10-12K lines.
Important: The
Registry
etc related classes will be going along withOriginInventory
. Therefore, theMemoryBackedRegistry
can no longer be used from Scala end-to-end tests. To keep the test coverage, all Scala end-to-end tests should be migrated to Kotlin functional test suite. TheMemoryBackedRegistry
provided a "back door" for configuring the old application router programmatically from Scala tests. The only alternative now is to use the styx RESTful admin interface API for reprogramming the routing object database. Just like the Kotlin e2e tests do.Part 2: Programmatic Configuration Objects
Commits:
Styx (proxy server) was originally designed to be a stand-alone application, not a library. Therefore the bootstrapping API for building and starting a styx proxy server was a complete afterthought. The biggest obstacle for providing a bootstrap API so far has been the routing object model, which was designed entirely around styx YAML configuration. These two commits demonstrate how to lift this restriction.
Currently, on
master
YAML is the only way to instantiate routing objects. For example:This PoC allows the above configuration to be injected programmatically in Java (or Kotlin) code:
Highlights:
There now is a clear separation between 1) Styx configuration object and its 2) instantiation.
The styx configuration objects are declarative data classes. They are the object's configuration. The configuration objects are for public consumption and they derive from
StyxObject<T>
. They have abuild
method to produce an instantiated object.An instantiated object implements data-plane or control plane, etc behaviour. They are always in private scope, and implement the interface
T
. For routing objects,T
is aRoutingObject
, it isInetServer
for server objects, etc.Custom Jackson serialisers to serialise/deserialise between Yaml representation and
StyxObject<T>
.There is no need to carry the yaml configuration around. The Yaml configuration is now deserialised to Styx objects, and injected into
StyxServerComponents
.