Documentation ¶
Overview ¶
Example ¶
s := New() endpoint := func(ip string, ready bool) *globalv1.EndpointInfo { return &globalv1.EndpointInfo{ Namespace: "default", SourceName: "svc0", ServiceName: "svc0", Conditions: &globalv1.EndpointConditions{ Ready: ready, }, Endpoint: &localv1.Endpoint{ IPs: &localv1.IPSet{V4: []string{ip}}, }, } } for _, twoReady := range []bool{true, false} { s.Update(func(tx *Tx) { tx.SetService(&localv1.Service{ Namespace: "default", Name: "svc0", }) tx.SetEndpointsOfSource("default", "svc0", []*globalv1.EndpointInfo{ endpoint("10.0.0.1", false), endpoint("10.0.0.2", twoReady), }) }) fmt.Println("two ready:", twoReady) infos := make([]*globalv1.EndpointInfo, 0) s.View(0, func(tx *Tx) { tx.EachEndpointOfService("default", "svc0", func(info *globalv1.EndpointInfo) { infos = append(infos, info) }) }) sort.Slice(infos, func(i, j int) bool { return infos[i].Endpoint.String() < infos[j].Endpoint.String() }) for _, info := range infos { fmt.Println("-", info.Endpoint, "[", info.Conditions, "]") } }
Output: two ready: true - IPs:{V4:"10.0.0.1"} [ ] - IPs:{V4:"10.0.0.2"} [ Ready:true ] two ready: false - IPs:{V4:"10.0.0.1"} [ ] - IPs:{V4:"10.0.0.2"} [ ]
Index ¶
- Constants
- Variables
- type Hashed
- type KV
- type Set
- type Store
- type Tx
- func (tx *Tx) AllSynced() bool
- func (tx *Tx) DelEndpointsOfSource(namespace, sourceName string)
- func (tx *Tx) DelNode(name string)
- func (tx *Tx) DelRaw(set Set, path string)
- func (tx *Tx) DelService(namespace, name string)
- func (tx *Tx) Each(set Set, callback func(*KV) bool)
- func (tx *Tx) EachEndpointOfService(namespace, serviceName string, callback func(*globalv1.EndpointInfo))
- func (tx *Tx) GetNode(name string) *globalv1.Node
- func (tx *Tx) IsSynced(set Set) bool
- func (tx *Tx) Reset()
- func (tx *Tx) SetEndpoint(ei *globalv1.EndpointInfo)
- func (tx *Tx) SetEndpointsOfSource(namespace, sourceName string, eis []*globalv1.EndpointInfo)
- func (tx *Tx) SetNode(n *globalv1.Node)
- func (tx *Tx) SetRaw(set Set, path string, value Hashed)
- func (tx *Tx) SetService(s *localv1.Service)
- func (tx *Tx) SetSync(set Set)
Examples ¶
Constants ¶
View Source
const ( Services = localv1.Set_GlobalServiceInfos Endpoints = localv1.Set_GlobalEndpointInfos Nodes = localv1.Set_GlobalNodeInfos )
Variables ¶
View Source
var AllSets = []Set{Services, Endpoints, Nodes}
Functions ¶
This section is empty.
Types ¶
type KV ¶
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
func (*Tx) DelEndpointsOfSource ¶
func (*Tx) DelService ¶
func (*Tx) Each ¶
Each iterate over each item in the given set, stopping if the callback returns false
func (*Tx) EachEndpointOfService ¶
func (tx *Tx) EachEndpointOfService(namespace, serviceName string, callback func(*globalv1.EndpointInfo))
func (*Tx) SetEndpoint ¶
func (tx *Tx) SetEndpoint(ei *globalv1.EndpointInfo)
func (*Tx) SetEndpointsOfSource ¶
func (tx *Tx) SetEndpointsOfSource(namespace, sourceName string, eis []*globalv1.EndpointInfo)
SetEndpointsOfSource replaces ALL endpoints of a single source (add new, update existing, delete removed)
func (*Tx) SetService ¶
Click to show internal directories.
Click to hide internal directories.