add support for load balancing across multiple models and providers #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces significant enhancements to the gateway's load balancing capabilities, focusing on ensuring that operations are only directed towards healthy providers. By integrating health checks across various points where providers and models are accessed or manipulated, we ensure higher reliability and availability in serving requests. This change affects how models and providers are listed, fetched, created, updated, and how their configurations are retrieved, ensuring that only healthy entities are interacted with. Code was created by Alex Scott and Sweep AI.
Summary
ListModels
,ListProviders
,GetProvider
,CreateProvider
,UpsertProvider
, andGetProviderConfig
methods withingateway/internal/api/v1/models.go
andproviders.go
to ensure operations are performed only on healthy providers.DefaultHealthChecker
struct ingateway/internal/router/health_checker.go
that currently assumes all providers are healthy. This serves as a placeholder for future, more sophisticated health check logic.PriorityRouter
andRoundRobinRouter
ingateway/internal/router/priority.go
andround_robin.go
to select the next available healthy provider, enhancing the robustness of load balancing mechanisms.Files affected:
gateway/internal/api/v1/models.go
gateway/internal/api/v1/providers.go
gateway/internal/router/health_checker.go
gateway/internal/router/priority.go
gateway/internal/router/round_robin.go