Plugin oriented architecture #30
jpbourgeon
started this conversation in
Ideas
Replies: 1 comment 4 replies
-
How do we decide between a discussion and an issue? This one seems ok as a discussion? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
More specifically, I am suggesting a plugin architecture. By systematically decoupling the SDK into a set of well-designed plugins, we can achieve greater robustness, better control over the workflow, and more freedom for experimentation. This approach is also beneficial for building our community, as a plugin architecture facilitates community experimentation and innovation without compromising the core project.
This would be good for building our community since an extensible architecture facilitates community experimentations and innovation, and at the same time helps the maintenance team protect the core perimeter.
As I see it, our architecture would need two types of plugins: adapters and middleware.
Adapters
For example, if we extract the
fetch
feature into an adapter, we can work on independent implementations such asnode18-http-adapter
(runtime fetch),undici-http-adapter
,node-fetch-http-adapter
(fornode.js < 14.x
), andbrowser-http-adapter
. We can also buildbun-http-adapter
,deno-http-adapter
,cloudflare-adapter
, and more. We could, I even create an ubiquitoushttp-adapter
that includes all of them and automatically detects and returns the right abstraction depending on the execution environment, at the cost of bundle size.This approach would also be beneficial for maintenance (simpler packages) and bundle size. We could build simpler adapters that handle a single responsibility, instead of shipping large packages. In the previous example, if one doesn't need to support the browser and only runs inside AWS Lambdas, they could drop the
http-adapter
for a smaller and more suitableundici-http-adapter
.A good candidate for an adapter would be the
signature-adapter
: it could rely on AWS SigV4 in early versions and then switch to a better alternative later on.Middlewares
Interestingly
@aws-sdk
introduced a middleware stack. I used it for latency measurement in the benchmark.From the current backlog, the middleware candidates I could identify are:
marshaller-middleware
fordynamodb
, and alogging-middleware
for our benchmarking.Example
In this example, I have omitted the proxy part for simplicity. The example declares a pseudo SDK class, extensible through adapters and middlewares. It is then instantiated with a dummy
undici-http-adapter
. After that, addb-marshaller-middleware
andddb-unmarshaller-middleware
are registered asbeforeRequest
andafterRequest
middleware respectively. Finally, therequest
function is called with a sample endpoint.Beta Was this translation helpful? Give feedback.
All reactions