• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang state.State类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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
}
开发者ID:luizbafilho,项目名称:fusis,代码行数:9,代码来源:bgp.go


示例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
}
开发者ID:luizbafilho,项目名称:fusis,代码行数:11,代码来源:iptables.go


示例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
}
开发者ID:luizbafilho,项目名称:fusis,代码行数:18,代码来源:monitor.go


示例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
}
开发者ID:luizbafilho,项目名称:fusis,代码行数:45,代码来源:ipvs.go


示例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
}
开发者ID:luizbafilho,项目名称:fusis,代码行数:10,代码来源:ipvs.go


示例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
}
开发者ID:luizbafilho,项目名称:fusis,代码行数:11,代码来源:ipam.go


示例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
}
开发者ID:luizbafilho,项目名称:fusis,代码行数:15,代码来源:vip.go


示例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
}
开发者ID:luizbafilho,项目名称:fusis,代码行数:22,代码来源:ipvs.go



注:本文中的github.com/luizbafilho/fusis/state.State类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang types.Service类代码示例发布时间:2022-05-23
下一篇:
Golang isolated.HexDigest类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap