Skip to content
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-resilience-http: Add documentation for capacity limiters #3082

Merged

Conversation

bryce-anderson
Copy link
Contributor

Motivation:

It could use some documentation.

Modifications:

Add it.

Motivation:

It could use some documentation.

Modifications:

Add it.
@bryce-anderson bryce-anderson marked this pull request as draft October 25, 2024 23:19
@bryce-anderson bryce-anderson marked this pull request as ready for review October 28, 2024 14:19
@@ -68,6 +68,10 @@ content:
branches: main
tags: [0.25.0, 0.26.0, 0.27.0, 0.28.0, 0.29.0, 0.30.0, 0.31.0, 0.32.0, 0.33.0, 0.34.0, 0.35.0, 0.36.0, 0.37.0, 0.38.0, 0.39.0, 0.40.0, 0.41.14, 0.42.50]
start_path: servicetalk-client-api/docs
- url: ../../
branches: main
tags: []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it need tags to show up in the built docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is right, but I don't actually know for sure so another opinion is welcome.

@bryce-anderson bryce-anderson requested a review from daschl October 29, 2024 17:29
Copy link
Contributor

@tkountis tkountis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daschl did the read proofing :D

@bryce-anderson
Copy link
Contributor Author

@daschl did the read proofing :D

And he did a much better job than I. 😄

@bryce-anderson bryce-anderson merged commit ec8ea4c into apple:main Oct 30, 2024
11 checks passed
@bryce-anderson bryce-anderson deleted the bl_anderson/CapacityLimiterDocs branch October 30, 2024 15:39
idelpivnitskiy added a commit to idelpivnitskiy/servicetalk that referenced this pull request Nov 13, 2024
Follow-up for apple#3082 to address some comments.
Copy link
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed some of the comments in #3098, others see below:

[#TrafficResiliency]
= Traffic Resiliency

Some examples that use the traffic resiliency features.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We typically clarify what those examples demonstrate and link to them. In this case, there are no clarifications on docs page nor javadoc in each example class.


HttpServers.forPort(0)
.appendNonOffloadingServiceFilter(resilienceFilter)
.listenAndAwait((ctx, request, responseFactory) -> Single.succeeded(responseFactory.ok()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use awaitShutdown() at the end, like in all other examples. Otherwise, it exists main block and users don't see the actual server running.
We assume that any example can be used as an example for starting a server, so it's good to show how they can present JVM app from exiting.

.classifier(() -> (meta) -> "/health".equals(meta.requestTarget()) ? () -> 20 : () -> 100)
.build();

HttpServers.forPort(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a standard port 8080 helps to make sure that when users start a server-side of an example, they can also run a client-side of an example to see it in action.


HttpClients.forSingleAddress("localhost", 8080)
.appendClientFilter(resilienceFilter)
.build();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming all examples can be used as learning material, it's better to always show that client should be closed after they are not required anymore. Using try-with-resources block consistently across all examples helps to preserve that.

try (HttpClient client = HttpClients.forSingleAddress("localhost", 8080)
.appendClientFilter(resilienceFilter)
.build()) {
// use client
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Examples are great when they can be run, even if they demonstrate something that is not visible via request logs.

// Initializing a Gradient limiter with configuration profile that favors lower latency.
// See the `.dynamicGradientOptimizeForThroughput()` variant to optimize for higher throughput.
@SuppressWarnings("unused")
final CapacityLimiter limiter = CapacityLimiters.dynamicGradientOptimizeForLatency()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How useful is this example if we already demonstrate how to build a limiter in other classes?

idelpivnitskiy added a commit that referenced this pull request Nov 13, 2024
Follow-up for #3082 to address some comments.
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.

4 participants