Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterStrategy ¶
func RegisterStrategy(strategy StrategyType, factory StrategyFactory)
Types ¶
type AddressResult ¶
type AddressResult struct {
// contains filtered or unexported fields
}
type GenericLoadBalancer ¶
Load balancer that can service request for any SRV record address
func NewGeneric ¶
func NewGeneric(cfg *Config) GenericLoadBalancer
Example ¶
Example of using a generic load balancer
srvName := "foo.service.fligl.io" cfg, err := DefaultConfig() if err != nil { panic(err) } lb := NewGeneric(cfg) add1, err := lb.Next(srvName) if err != nil { panic(err) } add2, err := lb.Next(srvName) if err != nil { panic(err) } adds := []dns.Address{add1, add2} sort.Sort(ByConnectionString(adds)) fmt.Printf("%s\n%s", adds[0], adds[1])
Output: 0.1.2.3:8001 4.5.6.7:8002
func NewRoundRobinStrategy ¶
func NewRoundRobinStrategy(lib dns.Lookup) GenericLoadBalancer
type LoadBalancer ¶
Load balancer that can service request for a configured SRV record address
func New ¶
func New(cfg *Config, address string) LoadBalancer
Example ¶
Example load balancer with defaults
cfg, err := DefaultConfig() if err != nil { panic(err) } lb := New(cfg, "foo.service.fligl.io") add1, err := lb.Next() if err != nil { panic(err) } add2, err := lb.Next() if err != nil { panic(err) } adds := []dns.Address{add1, add2} sort.Sort(ByConnectionString(adds)) fmt.Printf("%s\n%s", adds[0], adds[1])
Output: 0.1.2.3:8001 4.5.6.7:8002
type ResultCache ¶
func NewCache ¶
func NewCache() *ResultCache
type RoundRobinClb ¶
type RoundRobinClb struct {
// contains filtered or unexported fields
}
type SRVLoadBalancer ¶
type SRVLoadBalancer struct { Lb GenericLoadBalancer Address string }
Default implementation for load balancing on a SRV record
type StaticLoadBalancer ¶
Specify an address to always return (good for compatibility and in test)
type StrategyFactory ¶
type StrategyFactory func(dns.Lookup) GenericLoadBalancer
Click to show internal directories.
Click to hide internal directories.