Documentation ¶
Overview ¶
Package membership provides Go types for dealing with various data formats used to advertize a server's presence using services like ZooKeeper or Etcd.
Index ¶
- func TCPAddrFromServerSetEndpoint(ep *ServerSetEndpoint) (*net.TCPAddr, error)
- type ConflictingAddressesError
- type ConflictingZonesError
- type GRPC
- type GRPCOperation
- type Interface
- type Roxy
- func (r *Roxy) AsGRPC(namedPort string) *GRPC
- func (r *Roxy) AsRoxyJSON() *RoxyJSON
- func (r *Roxy) AsServerSet() *ServerSet
- func (r *Roxy) FromGRPC(grpc *GRPC) error
- func (r *Roxy) FromRoxyJSON(x *RoxyJSON) error
- func (r *Roxy) FromServerSet(ss *ServerSet) error
- func (r *Roxy) IsAlive() bool
- func (r *Roxy) MarshalJSON() ([]byte, error)
- func (r *Roxy) NamedAddr(namedPort string) *net.TCPAddr
- func (r *Roxy) NamedPorts() []string
- func (r *Roxy) PrimaryAddr() *net.TCPAddr
- func (r *Roxy) UnmarshalJSON(raw []byte) error
- type RoxyJSON
- type ServerSet
- type ServerSetEndpoint
- type ServerSetStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TCPAddrFromServerSetEndpoint ¶
func TCPAddrFromServerSetEndpoint(ep *ServerSetEndpoint) (*net.TCPAddr, error)
TCPAddrFromServerSetEndpoint is a helper function that parses an existing ServerSetEndpoint to produce a TCPAddr.
Types ¶
type ConflictingAddressesError ¶ added in v0.4.7
ConflictingAddressesError represents a conflicting attempt to use two different IP addresses to refer to the same server. The ServerSet format supports this, but Roxy format does not.
func (ConflictingAddressesError) Error ¶ added in v0.4.7
func (err ConflictingAddressesError) Error() string
Error fulfills the error interface.
type ConflictingZonesError ¶ added in v0.4.7
ConflictingZonesError represents a conflicting attempt to use two different IPv6 zones to refer to the same server. The ServerSet format supports this, but Roxy format does not.
func (ConflictingZonesError) Error ¶ added in v0.4.7
func (err ConflictingZonesError) Error() string
Error fulfills the error interface.
type GRPC ¶
type GRPC struct { Op GRPCOperation `json:"Op"` Addr string `json:"Addr"` Metadata interface{} `json:"Metadata,omitempty"` }
GRPC represents a service advertisement in etcd.io's gRPC Naming format.
See: https://etcd.io/docs/v3.4/dev-guide/grpc_naming/
func (*GRPC) IsAlive ¶ added in v0.4.4
IsAlive returns true if this represents the advertisement of a live server.
func (*GRPC) NamedAddr ¶ added in v0.4.4
NamedAddr returns the server's named endpoint as a TCPAddr.
(For GRPC format, this always panics for non-"" namedPort.)
func (*GRPC) NamedPorts ¶ added in v0.4.4
NamedPorts returns the list of named ports advertized by the server.
(For GRPC format, this is always the nil list.)
func (*GRPC) PrimaryAddr ¶ added in v0.4.4
PrimaryAddr returns the server's primary endpoint as a TCPAddr.
type GRPCOperation ¶
type GRPCOperation uint8
GRPCOperation represents the status of the server being advertized.
const ( GRPCOpAdd GRPCOperation = iota GRPCOpDelete )
GRPCOperation constants:
GRPCOpAdd healthy GRPCOpDelete not healthy
func (GRPCOperation) GoString ¶
func (op GRPCOperation) GoString() string
GoString fulfills fmt.GoStringer.
func (GRPCOperation) MarshalJSON ¶
func (op GRPCOperation) MarshalJSON() ([]byte, error)
MarshalJSON fulfills json.Marshaler.
func (*GRPCOperation) UnmarshalJSON ¶
func (op *GRPCOperation) UnmarshalJSON(raw []byte) error
UnmarshalJSON fulfills json.Unmarshaler.
type Interface ¶ added in v0.4.4
type Interface interface { IsAlive() bool NamedPorts() []string PrimaryAddr() *net.TCPAddr NamedAddr(string) *net.TCPAddr }
Interface is the minimum interface supported by all advertisement formats.
type Roxy ¶
type Roxy struct { Ready bool IP net.IP Zone string ServerName string PrimaryPort uint16 AdditionalPorts map[string]uint16 ShardNumber uint32 HasShardNumber bool Metadata map[string]string }
Roxy represents a service advertisement in Roxy's native format.
See RoxyJSON for details about the JSON serialization format.
func (*Roxy) AsRoxyJSON ¶
AsRoxyJSON returns the RoxyJSON representation of this server advertisement.
func (*Roxy) AsServerSet ¶
AsServerSet returns the ServerSet representation of this server advertisement.
func (*Roxy) FromRoxyJSON ¶
FromRoxyJSON initializes this server advertisement to be a copy of a RoxyJSON.
func (*Roxy) FromServerSet ¶
FromServerSet initializes this server advertisement to be a copy of a ServerSet.
func (*Roxy) IsAlive ¶ added in v0.4.4
IsAlive returns true if this represents the advertisement of a live server.
func (*Roxy) MarshalJSON ¶
MarshalJSON fulfills json.Marshaler.
func (*Roxy) NamedPorts ¶
NamedPorts returns the list of named ports advertized by the server.
func (*Roxy) PrimaryAddr ¶
PrimaryAddr returns the server's primary endpoint as a TCPAddr.
func (*Roxy) UnmarshalJSON ¶
UnmarshalJSON fulfills json.Unmarshaler.
type RoxyJSON ¶
type RoxyJSON struct { Ready bool `json:"ready"` IP string `json:"ip,omitempty"` Zone string `json:"zone,omitempty"` ServerName string `json:"serverName,omitempty"` PrimaryPort uint16 `json:"primaryPort,omitempty"` AdditionalPorts map[string]uint16 `json:"additionalPorts,omitempty"` ShardNumber *uint32 `json:"shard,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` }
RoxyJSON is a variant of Roxy, ready for JSON serialization.
Compared to Roxy, RoxyJSON serializes IP addresses in the usual string format, rather than representing them as net.IP byte arrays.
type ServerSet ¶
type ServerSet struct { ServiceEndpoint *ServerSetEndpoint `json:"serviceEndpoint"` AdditionalEndpoints map[string]*ServerSetEndpoint `json:"additionalEndpoints"` Status ServerSetStatus `json:"status"` ShardNumber *int32 `json:"shard,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` }
ServerSet represents a service advertisement in Finagle's ServerSet format.
func (*ServerSet) IsAlive ¶
IsAlive returns true if this represents the advertisement of a live server.
func (*ServerSet) NamedAddr ¶ added in v0.4.4
NamedAddr returns the server's named endpoint as a TCPAddr.
func (*ServerSet) NamedPorts ¶ added in v0.4.4
NamedPorts returns the list of named ports advertized by the server.
func (*ServerSet) PrimaryAddr ¶ added in v0.4.4
PrimaryAddr returns the server's primary endpoint as a TCPAddr.
type ServerSetEndpoint ¶
ServerSetEndpoint represents a single endpoint in a ServerSet advertisement.
Each server's ServerSet can contain one primary and multiple named endpoints.
func ServerSetEndpointFromTCPAddr ¶
func ServerSetEndpointFromTCPAddr(addr *net.TCPAddr) *ServerSetEndpoint
ServerSetEndpointFromTCPAddr is a helper function that creates a new ServerSetEndpoint representing the given TCPAddr.
func (*ServerSetEndpoint) Addr ¶ added in v0.4.4
func (ep *ServerSetEndpoint) Addr() *net.TCPAddr
Addr returns this endpoint as a TCPAddr. Panics if the endpoint data cannot be parsed as an IP and port.
type ServerSetStatus ¶
type ServerSetStatus uint8
ServerSetStatus represents the status of the server being advertized.
const ( StatusDead ServerSetStatus = iota StatusStarting StatusAlive StatusStopping StatusStopped StatusWarning )
ServerSetStatus constants:
StatusAlive healthy anything else not healthy
func (ServerSetStatus) GoString ¶
func (status ServerSetStatus) GoString() string
GoString fulfills fmt.GoStringer.
func (ServerSetStatus) MarshalJSON ¶
func (status ServerSetStatus) MarshalJSON() ([]byte, error)
MarshalJSON fulfills json.Marshaler.
func (ServerSetStatus) String ¶
func (status ServerSetStatus) String() string
String fulfills fmt.Stringer.
func (*ServerSetStatus) UnmarshalJSON ¶
func (status *ServerSetStatus) UnmarshalJSON(raw []byte) error
UnmarshalJSON fulfills json.Unmarshaler.