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

Refactor Node Penalties into an interface that can be overriden by consumers #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kikkia
Copy link
Contributor

@kikkia kikkia commented Mar 27, 2024

The Penalties member of the LavaLinkNode provides a health based penalty tracker for the node. By refactoring this into an interface INodeHealthProvider we can better encapsulate its function compared to the IPenaltyProvider.

That penalties member is also not configurable for the user of the library, locking them into the default node health based loadbalancing, or overriding the default loadbalancer and having this class "dangle" still around but not doing anything except waste some cycles listening to events.

I am not married to the naming I chose here so super open to changing that + package structure. Just throwing this out there for the first pass towards unlocking some more control over the loadbalancing and controlling what players are on what nodes.

Right now the concept of nodes being either available or unavailable based soley on connection to the server is hindering the ability to correct for transient errors.

Open to discussion or feedback on the way y'all are open to solving this problem. In theory the simplest way would just be to open the Link.transferNode function and then let users create their own custom loadbalancer that does not pay attention to the Node Penalties tracker I am refactoring here, and keep track of all of that themselves.

…out into an interface to allow for overriding.
@duncte123
Copy link
Collaborator

Open to discussion or feedback on the way y'all are open to solving this problem. In theory the simplest way would just be to open the Link.transferNode function and then let users create their own custom loadbalancer that does not pay attention to the Node Penalties tracker I am refactoring here, and keep track of all of that themselves.

I think it would be better if LavalinkClient got an optional parameter that would allow for overriding the entire loadbalancer that way. I think that there already is an interface for that (maybe even a setter as well)

@kikkia
Copy link
Contributor Author

kikkia commented Mar 27, 2024

Will take a look at that when I get some time in a day or so. Thanks

import dev.arbjerg.lavalink.client.loadbalancing.MAX_ERROR
import dev.arbjerg.lavalink.protocol.v4.Message

interface INodeHealthProvider {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be a good idea to turn this into an abstract class? That way you could enforce a default constructor that always takes the lavalink node as argument. I feel like it would be difficult to get at some of the required stats from the node otherwise. I feel like builder can be changed to accept a function with the node as single argument for the provider

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.

None yet

2 participants