Documentation
¶
Overview ¶
Package core provides components useful for containing and retrieving entities, i.e. Sources, using a defined strategy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Balancer ¶
type Balancer struct { Strategy // contains filtered or unexported fields }
Balancer distributes work to set of sources, using a particular strategy. The zero value of the Balancer is ready to use and safe to be used by multiple gorountines.
func (*Balancer) Get ¶
Get returns a Source from the balancer's source list using the predefined Strategy. If no Strategy was provided, Get returns a Source using RoundRobin.
func (*Balancer) Put ¶
Put adds ss as sources to the current balancer ring. If ss.len() == 0, Put silently returns, otherwise it constracts a Ring with the provided sources. If the balancer has already a ring, pointing lets say to 0, it adds the ring at position -1, preserving the balancer's ring position. If the balancer does not have a ring yet, the new ring will be used, making it point to the first source provided in the list.
type Dialer ¶
type Dialer interface { // DialContext dials connections with address using the specified network. DialContext(ctx context.Context, network, address string) (net.Conn, error) }
Dialer is a wrapper around the DialContext function.
type Ring ¶
Ring is a proxy struct around a container/ring. It forces to use Source as Value instead of bare interface{}.
func NewRingSources ¶
type Source ¶
type Source interface { Dialer // ID uniquely identifies a source. ID() string // Tells the receiver to cleanup and close all connections. Close() error }
Source represents an entity that is able to provide network connections and keep a set of metrics regarding the operations that is performing, or has performed.