Documentation
¶
Overview ¶
Package preferencebalancer registers a gRPC balancer that strictly prefers some servers over others. If multiple preferred servers are available, they are used in round robin. If no preferred server is available, the rest are used in round robin.
Make sure to import this package, for example with:
import _ "github.com/Jille/grpc-preference-balancer"
This balancer can be used with a service config like:
{"loadBalancingPolicy": "preference_balancer", "loadBalancingConfig": [{"preference_balancer": {"preferredEndpoints": ["127.0.0.1:1234"]}}]}
A service config can for example be given with google.golang.org/grpc.WithDefaultServiceConfig (and enforced with google.golang.org/grpc.WithDisableServiceConfig to ignore the resolvers ServiceConfig).
Index ¶
Constants ¶
const Name = "preference_balancer"
Variables ¶
This section is empty.
Functions ¶
func SimpleServiceConfig ¶
SimpleServiceConfig is an optional helper function to write a service config for you.
Types ¶
type LBConfig ¶
type LBConfig struct {
serviceconfig.LoadBalancingConfig `json:"-"`
PreferredEndpoints []string `json:"preferredEndpoints,omitempty"`
}
LBConfig is the balancer config for the preference balancer.