Skip to content

apply traffic shaping on subgraph directly#2034

Merged
Geal merged 12 commits intodevfrom
geal/traffic-shaping-refactoring
Nov 7, 2022
Merged

apply traffic shaping on subgraph directly#2034
Geal merged 12 commits intodevfrom
geal/traffic-shaping-refactoring

Conversation

@Geal
Copy link
Contributor

@Geal Geal commented Oct 31, 2022

The plugin infrastructure works on BoxService instances, and makes no guarantee on plugin ordering.
The traffic shaping plugin needs a clonable inner service, and should run right before calling
the underlying service. So this changes the traffic plugin application so it can work directly
on the underlying service. It is still a plugin though, so it keeps the same configuration.

traffic shaping layers tend to require clonable services and a specific
ordering, so we apply them manually instead of relying on
Plugin::subgraph_service, which only works on BoxService and has no
ordering guarantee
@github-actions

This comment has been minimized.

@Geal Geal requested review from BrynCooke and bnjjj November 2, 2022 09:43
@Geal Geal marked this pull request as ready for review November 2, 2022 13:32
@Geal Geal mentioned this pull request Nov 3, 2022
4 tasks
@BrynCooke
Copy link
Contributor

Is there a way we could extend the existing functionality around plugins ordering to allow traffic shaping to be moved to last?
https://github.com/apollographql/router/blob/dev/apollo-router/src/router_factory.rs#L228

If this would work then I think it'd be cleaner.

@Geal
Copy link
Contributor Author

Geal commented Nov 4, 2022

we could, but the service it manipulates would still be a BoxService, which is not clonable. And we need a clonable service for deduplication (that was done manually here before https://github.com/apollographql/router/pull/2034/files#diff-67b9590c5fe973fea43d5bc5a29f37da7b961823665694909f45a00ec50e873dL131 ), timeout, retries and caching

@Geal Geal enabled auto-merge (squash) November 7, 2022 10:22
@Geal Geal merged commit 0b1cb26 into dev Nov 7, 2022
@Geal Geal deleted the geal/traffic-shaping-refactoring branch November 7, 2022 10:38
@abernix abernix mentioned this pull request Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants