lavalink-devs / lavalink-client

Lavalink client for lavalink v4
https://lavalink.dev/
MIT License
16 stars 5 forks source link

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

Open kikkia opened 7 months ago

kikkia commented 7 months ago

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.

duncte123 commented 7 months ago

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.transferNodefunction 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 commented 7 months ago

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