-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Traffic shaping for connectors #6737
Conversation
✅ Docs preview has no changesThe preview was not built because there were no changes. Build ID: 872f6b6d11aa1f1fd4e68499 |
This comment has been minimized.
This comment has been minimized.
CI performance tests
|
…ove deduplicate query from the options
…s after fixing the RouterBody/String problem.
"description": "#/definitions/Compression", | ||
"nullable": true | ||
}, | ||
"dns_resolution_strategy": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
am i correct in reading that dns_resolution_strategy
and experimental_http2
aren't tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not explicitly write tests for them because the existing traffic shaping also doesn't.
My interpretation as to why is because while these settings are in traffic shaping, the actual logic/functionality for them is used elsewhere in other parts of the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
were there things you had to test this way (using this new mock service and the tests in plugins/traffic_shaping/mod.rs) that warrant two ways of testing? i'm wondering if we can kill this in favor or tests/integration/traffic_shaping.rs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm be fine with doing just the integration tests.
I did both ways mostly to match what was already being done in the existing tests.... but I'm not married to it. I tend to monkey-see-monkey-do when touching existing code. :D
@@ -231,6 +231,16 @@ impl Connector { | |||
.map_err(|_| internal_error!("Failed to create key for connector {}", self.id.label)), | |||
} | |||
} | |||
|
|||
/// Create an identifier for this connector that can be used for configuration and service identification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you document the behavior when source is None and why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some more comment!
@@ -1608,6 +1607,14 @@ snapshot_kind: text | |||
"description": "#/definitions/RouterShaping", | |||
"nullable": true | |||
}, | |||
"sources": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned this in a doc comment but you might have missed it - we need an additional connector:
layer here, above sources
.
.sources | ||
.get(&source_name) | ||
.map(|connector_config| connector_config.clone().into()); | ||
let final_config = Self::merge_config(all_config, source_config.as_ref()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although ConnectorShaping
always sets deduplicate_query
to None
, this merge will cause it to be set if the all
config has it set. See here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did this get addressed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! This was a problem because before the all
config was the subgraph config which could contain deduplicate_query
whereas now the merge will be two connector configs.
@@ -423,6 +424,31 @@ pub(crate) async fn create_http_services( | |||
let http_service_factory = HttpClientServiceFactory::new(http_service, plugins.clone()); | |||
http_services.insert(name.clone(), http_service_factory); | |||
} | |||
|
|||
// Also create client service factories for connector sources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll have already redundantly created an HttpClientServiceFactory
above for the expanded connector subgraph, and that one will no longer be used by the ConnectorRequestService
. We should find a way to not create that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would creating a list of "connector subgraph names" prior to that loop and doing a comparison of the subgraph name versus the connector subgraph name suffice?
Basically... if we have a subgraph name that matches a connector subgraph name... don't add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented what I stated above!
@@ -103,7 +103,7 @@ pub(crate) fn make_request( | |||
transport.body.as_ref().map(|body| SelectionData { | |||
source: body.to_string(), | |||
transformed: body.to_string(), // no transformation so this is the same | |||
result: json_body, | |||
result: json_body.clone(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add this clone? It seems unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got left in from a previous iteration of this PR.. removed!
), | ||
) | ||
.boxed() | ||
pub(crate) fn create(&self, source_name: String) -> BoxService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CONNECT_REQUEST_SPAN_NAME
span used to be created here - where does that happen now? I'm not finding it. It should likely move to the telemetry plugin connect_request_service
method via span_factory
like it is for subgraph service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah crap, definitely accidentally nuked it. I'll look at adding it back!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it back as suggested!
@@ -49,7 +49,7 @@ pub(crate) enum HandleResponseError { | |||
|
|||
// --- RAW RESPONSE ------------------------------------------------------------ | |||
|
|||
enum RawResponse { | |||
pub(crate) enum RawResponse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why pub(crate)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got left in from a previous iteration of this PR.. removed!
@@ -940,6 +953,17 @@ impl PluggableSupergraphServiceBuilder { | |||
.and_then(|plugin| (*plugin.1).as_any().downcast_ref::<Subscription>()) | |||
.map(|p| p.config.clone()); | |||
|
|||
let connector_sources: HashSet<String> = schema | |||
.connectors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we just make a getter on the Connectors
struct for this? no need to compute it more than once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify, this is to reduce some repetition since this exact code block is done in a couple of places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, both the set of subgraphs and set of source config keys can be calculated once at schema load time.
@@ -203,7 +203,7 @@ impl RawResponse { | |||
} | |||
|
|||
// --- MAPPED RESPONSE --------------------------------------------------------- | |||
#[derive(Debug)] | |||
#[derive(Debug, Clone)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remind me why this is clone? maybe even add a comment for future readers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must have accidentally left it in from a previous iteration of code 😓 removed!
Example config:
Checklist
Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.
Exceptions
Note any exceptions here
Notes
Footnotes
It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. ↩
Configuration is an important part of many changes. Where applicable please try to document configuration examples. ↩
Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions. ↩