本文整理汇总了Golang中github.com/weaveworks/flux/common/store.Store.GetAllServices方法的典型用法代码示例。如果您正苦于以下问题:Golang Store.GetAllServices方法的具体用法?Golang Store.GetAllServices怎么用?Golang Store.GetAllServices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/weaveworks/flux/common/store.Store
的用法示例。
在下文中一共展示了Store.GetAllServices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testServices
func testServices(s store.Store, t *testing.T) {
require.Nil(t, s.AddService("svc", testService))
svc2, err := s.GetService("svc", store.QueryServiceOptions{})
require.Nil(t, err)
require.Equal(t, "svc", svc2.Name)
require.Equal(t, testService, svc2.Service)
require.Nil(t, s.CheckRegisteredService("svc"))
services := func() map[string]data.Service {
svcs := make(map[string]data.Service)
ss, err := s.GetAllServices(store.QueryServiceOptions{})
require.Nil(t, err)
for _, svc := range ss {
svcs[svc.Name] = svc.Service
}
return svcs
}
require.Equal(t, map[string]data.Service{"svc": testService}, services())
require.Nil(t, s.RemoveService("svc"))
require.Equal(t, map[string]data.Service{}, services())
require.Nil(t, s.AddService("svc", testService))
require.Nil(t, s.RemoveAllServices())
require.Equal(t, map[string]data.Service{}, services())
}
示例2: allServices
func allServices(t *testing.T, st store.Store) []*store.ServiceInfo {
services, err := st.GetAllServices(store.QueryServiceOptions{})
require.NoError(t, err)
return services
}