Documentation ¶
Index ¶
- func IsEqual(h1, h2 *Host) bool
- type Host
- type Set
- func (set *Set) Add(hosts ...*Host)
- func (set *Set) All() []*Host
- func (set *Set) Exist(addr string) bool
- func (set *Set) Healthy() (hosts []*Host)
- func (set *Set) Len() int
- func (set *Set) MarkHostHealthy(host *Host) bool
- func (set *Set) MarkHostUnhealthy(host *Host) bool
- func (set *Set) Random() *Host
- func (set *Set) Remove(hosts ...*Host)
- func (set *Set) ReplaceAll(hosts []*Host)
- type Stats
- func (stats *Stats) ConnBytesInCounter() *atomic.Uint64
- func (stats *Stats) ConnBytesOutCounter() *atomic.Uint64
- func (stats *Stats) ConnCount() uint64
- func (stats *Stats) DecConnCount()
- func (stats *Stats) IncConnCount()
- func (stats *Stats) IncFailedCount() uint64
- func (stats *Stats) IncSuccessfulCount() uint64
- func (stats *Stats) MarshalJSON() ([]byte, error)
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Host ¶
Host represents a backend host.
func NewWithType ¶
NewWithType creates a host instance with specified type.
func (*Host) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*Host) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
func (*Host) WaitRemoved ¶
func (h *Host) WaitRemoved() <-chan struct{}
WaitRemoved close when this host removed.
type Set ¶
Set is a hosts container.
func (*Set) MarkHostHealthy ¶
MarkHostHealthy marks the given host as healthy.
func (*Set) MarkHostUnhealthy ¶
MarkHostUnhealthy marks the given host as unhealthy.
func (*Set) ReplaceAll ¶
ReplaceAll replaces the internal hosts atomicly.
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
Stats describes the stats of a host.
func (*Stats) ConnBytesInCounter ¶
ConnBytesInCounter return input bytes counter.
func (*Stats) ConnBytesOutCounter ¶
ConnBytesOutCounter return output bytes counter.
func (*Stats) DecConnCount ¶
func (stats *Stats) DecConnCount()
DecConnCount decreases the connection count by 1.
func (*Stats) IncConnCount ¶
func (stats *Stats) IncConnCount()
IncConnCount increases the connection count by 1.
func (*Stats) IncFailedCount ¶
IncFailedCount increase failed count by 1 and clears successful count.
func (*Stats) IncSuccessfulCount ¶
IncSuccessfulCount increase successful count by 1 and clears failed count.
func (*Stats) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type Type ¶
type Type int
Type indicates the type of host.
func ParseType ¶
ParseType always returns a valid Type. If given "backup", it returns TypeBackup. Otherwise it returns TypeMain.
func (Type) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Type) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface.