當前位置: 首頁>>代碼示例>>Golang>>正文


Golang state.State類代碼示例

本文整理匯總了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;未經允許,請勿轉載。