本文整理汇总了Golang中github.com/luizbafilho/fusis/state.State类的典型用法代码示例。如果您正苦于以下问题:Golang State类的具体用法?Golang State怎么用?Golang State使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了State类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getStateBgpPaths
func (bs *BgpService) getStateBgpPaths(s state.State) mapset.Set {
paths := mapset.NewSet()
for _, v := range s.GetServices() {
paths.Add(v.Address)
}
return paths
}
示例2: getNatServices
func (i IptablesMngr) getNatServices(s state.State) []types.Service {
natServices := []types.Service{}
for _, svc := range s.GetServices() {
if svc.IsNat() {
natServices = append(natServices, svc)
}
}
return natServices
}
示例3: FilterHealthy
func (m *FusisMonitor) FilterHealthy(s state.State) state.State {
filteredState := s.Copy()
for _, svc := range filteredState.GetServices() {
for _, dst := range filteredState.GetDestinations(&svc) {
checkId := fmt.Sprintf("%s:%s", svc.GetId(), dst.GetId())
m.RLock()
if check, ok := m.runningChecks[checkId]; ok {
if check.GetStatus() == BAD {
logrus.Debugf("[health-monitor] filtering %#v. Check %s", dst, check.GetId())
filteredState.DeleteDestination(&dst)
}
}
m.RUnlock()
}
}
return filteredState
}
示例4: Sync
// Sync syncs all ipvs rules present in state to kernel
func (ipvs *Ipvs) Sync(state state.State) error {
ipvs.Lock()
defer ipvs.Unlock()
log.Debug("[ipvs] Syncing")
stateSet := ipvs.getStateServicesSet(state)
currentSet, err := ipvs.getCurrentServicesSet()
if err != nil {
return err
}
rulesToAdd := stateSet.Difference(currentSet)
rulesToRemove := currentSet.Difference(stateSet)
// Adding services and destinations missing
for r := range rulesToAdd.Iter() {
service := r.(types.Service)
dsts := state.GetDestinations(&service)
if err := ipvs.addServiceAndDestinations(service, dsts); err != nil {
return err
}
log.Debugf("[ipvs] Added service: %#v with destinations: %#v", service, dsts)
}
// Cleaning rules
for r := range rulesToRemove.Iter() {
service := r.(types.Service)
err := gipvs.DeleteService(*ToIpvsService(&service))
if err != nil {
return err
}
log.Debugf("[ipvs] Removed service: %#v", service)
}
// Syncing destination rules
for _, s := range state.GetServices() {
if err := ipvs.syncDestinations(state, s); err != nil {
return err
}
}
return nil
}
示例5: getStateServicesSet
func (ipvs *Ipvs) getStateServicesSet(state state.State) mapset.Set {
stateSet := mapset.NewSet()
for _, s := range state.GetServices() {
s.Name = ""
s.Mode = ""
stateSet.Add(s)
}
return stateSet
}
示例6: ipIsAssigned
func (i *Ipam) ipIsAssigned(e string, state state.State) bool {
services := state.GetServices()
for _, a := range services {
if a.Address == e {
return true
}
}
return false
}
示例7: getStateVips
func (n VipMngr) getStateVips(state state.State) mapset.Set {
vips := []string{}
svcs := state.GetServices()
for _, s := range svcs {
vips = append(vips, s.Address)
}
set := mapset.NewSet()
for _, v := range vips {
set.Add(v)
}
return set
}
示例8: getStateDestinationsSet
func (ipvs *Ipvs) getStateDestinationsSet(state state.State, svc types.Service) mapset.Set {
// checks := state.GetChecks()
stateSet := mapset.NewSet()
// Filter healthy destinations
for _, d := range state.GetDestinations(&svc) {
// if check, ok := checks[d.GetId()]; ok {
// if check.Status == health.BAD {
// continue
// }
// } else { // no healthcheck found
// continue
// }
// Clean up to match services from kernel
d.Name = ""
d.ServiceId = ""
stateSet.Add(d)
}
return stateSet
}