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

Add http timeout configuration for nodes #22

Merged
merged 8 commits into from
Feb 19, 2024

Conversation

kikkia
Copy link
Contributor

@kikkia kikkia commented Feb 11, 2024

Currently nodes only use the default HTTP timeouts set by OKHTTP, which are:

  • Connect: 10sec
  • Read: 10sec
  • Write: 10sec
  • Call: No timeout

This PR allows the consumer to set an optional total call timeout. It utilizes the currently unused constant TIMEOUT_MS and changes that to a default of 10sec per request. 10 seconds was chosen to avoid moving the timeout up too much from what it is now, 10 sec to connect, 10 more sec to finish read/write op. I doubt many users have latency > 5s but it avoids someone from getting a regression if they do.

Copy link
Collaborator

@duncte123 duncte123 left a comment

Choose a reason for hiding this comment

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

Looks good at first glance, just a few changes I would recommend making

*/
@JvmOverloads
fun addNode(name: String, address: URI, password: String, regionFilter: IRegionFilter? = null): LavalinkNode {
fun addNode(name: String, address: URI, password: String, regionFilter: IRegionFilter? = null, httpTimeout: Long = TIMEOUT_MS): LavalinkNode {
Copy link
Collaborator

@duncte123 duncte123 Feb 11, 2024

Choose a reason for hiding this comment

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

With how many parameters there currently are, it may be better to deprecate this method and create a method that accepts a builder instead.

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 was thinking a builder or some sort of node options class that can be extended with all of these

Copy link
Collaborator

Choose a reason for hiding this comment

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

That sounds good to me. Something like new NodeOptions.Builder().build() -> NodeOptions

@kikkia
Copy link
Contributor Author

kikkia commented Feb 14, 2024

Added the LavalinkNodeOptions builder, can add some javadocs if you want, but left em out for now because they seem kinda straightforward

Copy link
Collaborator

@duncte123 duncte123 left a comment

Choose a reason for hiding this comment

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

LGTM

@duncte123 duncte123 merged commit 08dabd4 into lavalink-devs:main Feb 19, 2024
1 of 2 checks passed
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.

2 participants