Documentation ¶
Index ¶
- Variables
- func NewNodes(cfg config.Config) (ms map[string]Manager, err error)
- func NewNodesFromConfig(filepath string) (map[string]Manager, error)
- type Manager
- func New(nt NodeType, name string) (Manager, error)
- func NewConsistent(name string) (Manager, error)
- func NewDirect(name string) (Manager, error)
- func NewRandom(name string) (Manager, error)
- func NewRoundRobin(name string) (Manager, error)
- func NewWithNodes(nt NodeType, name string, nodes []*Node) (Manager, error)
- type Node
- func (x *Node) Copy() *Node
- func (*Node) Descriptor() ([]byte, []int)deprecated
- func (x *Node) Get(key string) (string, bool)
- func (x *Node) GetHeartbeat() uint64
- func (x *Node) GetMetadata() map[string]string
- func (x *Node) GetNumber() uint32
- func (x *Node) GetProtocol() Protocol
- func (x *Node) GetTTL() uint64
- func (x *Node) GetValue() string
- func (x *Node) GetWeight() uint32
- func (*Node) ProtoMessage()
- func (x *Node) ProtoReflect() protoreflect.Message
- func (x *Node) Reset()
- func (x *Node) Set(key, value string)
- func (x *Node) String() string
- type NodeType
- type Protocol
Constants ¶
This section is empty.
Variables ¶
View Source
var ( NodeType_name = map[int32]string{ 0: "NODE_TYPE_DIRECT", 1: "NODE_TYPE_RANDOM", 2: "NODE_TYPE_CONSISTENT", 3: "NODE_TYPE_ROUNDROBIN", } NodeType_value = map[string]int32{ "NODE_TYPE_DIRECT": 0, "NODE_TYPE_RANDOM": 1, "NODE_TYPE_CONSISTENT": 2, "NODE_TYPE_ROUNDROBIN": 3, } )
Enum value maps for NodeType.
View Source
var ( Protocol_name = map[int32]string{ 0: "PROTOCOL_LOCAL", 1: "PROTOCOL_GRPC", 2: "PROTOCOL_HTTP", 3: "PROTOCOL_QUIC", } Protocol_value = map[string]int32{ "PROTOCOL_LOCAL": 0, "PROTOCOL_GRPC": 1, "PROTOCOL_HTTP": 2, "PROTOCOL_QUIC": 3, } )
Enum value maps for Protocol.
View Source
var File_trellis_tech_trellis_v1_proto_node_proto protoreflect.FileDescriptor
Functions ¶
Types ¶
type Manager ¶
type Manager interface { // Add adds a node to the node ring. Add(node *Node) // NodeFor get the node responsible for the data key. NodeFor(keys ...string) (*Node, bool) // Remove removes all nodes from the node ring. Remove() // RemoveByValue removes a node from the node ring. RemoveByValue(id string) // PrintNodes print all nodes PrintNodes() // IsEmpty is the node ring empty IsEmpty() bool }
Manager node manager functions defines.
func NewConsistent ¶
NewConsistent get consistent node manager
func NewRoundRobin ¶
NewRoundRobin get round robin node manager
type Node ¶
type Node struct { // @gotags: json:"weight" yaml:"weight" Weight uint32 `protobuf:"varint,1,opt,name=weight,proto3" json:"weight" yaml:"weight"` // @gotags: json:"value" yaml:"value" Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value" yaml:"value"` // @gotags: json:"ttl" yaml:"ttl" TTL uint64 `protobuf:"varint,3,opt,name=TTL,proto3" json:"ttl" yaml:"ttl"` // @gotags: json:"heartbeat" yaml:"heartbeat" Heartbeat uint64 `protobuf:"varint,4,opt,name=heartbeat,proto3" json:"heartbeat" yaml:"heartbeat"` // @gotags: json:"protocol" yaml:"protocol" Protocol Protocol `protobuf:"varint,5,opt,name=protocol,proto3,enum=node.Protocol" json:"protocol" yaml:"protocol"` // @gotags: protobuf:"-" json:"-" yaml:"-" Number uint32 `protobuf:"-" json:"-" yaml:"-"` // @gotags: json:"metadata" yaml:"metadata" Metadata map[string]string `` /* 163-byte string literal not displayed */ // contains filtered or unexported fields }
func (*Node) Descriptor
deprecated
func (*Node) GetHeartbeat ¶
func (*Node) GetMetadata ¶
func (*Node) GetProtocol ¶
func (*Node) ProtoMessage ¶
func (*Node) ProtoMessage()
func (*Node) ProtoReflect ¶
func (x *Node) ProtoReflect() protoreflect.Message
type NodeType ¶
type NodeType int32
func (NodeType) Descriptor ¶
func (NodeType) Descriptor() protoreflect.EnumDescriptor
func (NodeType) EnumDescriptor
deprecated
func (NodeType) Number ¶
func (x NodeType) Number() protoreflect.EnumNumber
func (NodeType) Type ¶
func (NodeType) Type() protoreflect.EnumType
type Protocol ¶
type Protocol int32
func (Protocol) Descriptor ¶
func (Protocol) Descriptor() protoreflect.EnumDescriptor
func (Protocol) EnumDescriptor
deprecated
func (Protocol) Number ¶
func (x Protocol) Number() protoreflect.EnumNumber
func (Protocol) Type ¶
func (Protocol) Type() protoreflect.EnumType
Click to show internal directories.
Click to hide internal directories.