Open bryanchriswhite opened 10 months ago
@bryanchriswhite I like the initative of this refactor. I moved it into our TECHDEBT iteration but lmk if you think it should be tended to sooner.
Two additional thoughts/comments:
RelayerMiddleware
under /pkg/relayer/middleware
middleware
is where gateways can add their own custom (e.g. quality-of-service) plugins@red-0ne to review in iteration 9 and sync with @bryanchriswhite to decide if this is necessary or not.
Objective
Add a degree of freedom for proxy consumers to configure middleware functions which the proxy will call at appropriate stages in the request/response pipeline.
Origin Document
Currently,
RelayServer
implementations, which are responsible for the request/response pipeline, don't expose any control over the shape of or flow through it. I.e., a validation stage (function) is applied before the relay is serviced and a signing stage (function) is applied after servicing the relay but before returning the response. While the implementation of these functions may lie outside of theRelayServer
implementation, it is still explicitly aware of which of them is called at what stage, with no opportunity for (re)configuration.If we add a "middleare" concept to the
RelayServer
which provides sufficient hooks into significant stages of the request/response pipeline we would reduceRelayServer
s awareness of an unrelated concern; instead of "validate here" and "sign here", it becomes "run this [current stage]'s middleware".We should consider whether it's necessary and/or appropriate to make the
RelayerProxy
aware of middleware as well. I could imagine use cases for both relayer-wide as well asRelayServer
-specific middleware)Goals
/pkg/relayer/proxy
package.Deliverables
relayer
pkg interface(s) as necessary to support middleware configuration.RelayServer
implementations to utilize middleware instead of directly calling validation & signing functions.RelayServer
consumers to provide middleware configuration(s).Non-goals / Non-deliverables
RelayServer
listener/handler functions beyond what's necessary to effect the middleware refactor.General deliverables
Creator: @bryanchriswhite Co-Owners: @red-0ne