Example #1
0
func (s *StaticDiscovery) Configure(namespace string) {
	if s.Namespace != "" {
		//TODO: use logging
		fmt.Errorf("%s already inited: %s", StaticFactoryKey, s.Namespace)
		return
	}
	s.Namespace = namespace
	instances := viper.GetStringSlice(util.GetStaticRegistryKey(s))
	fmt.Printf("instances %+v\n", instances)
	s.Instances = instances
}
func assertRegistry(t *testing.T, registry Registry) []string {
	registry.Register(util.Instance{Id: "1", Host: "127.0.0.1", Port: 8080})
	registry.Register(util.Instance{Id: "2", Host: "localhost", Port: 9080})

	servers := viper.GetStringSlice(util.GetStaticRegistryKey(registry))

	require.NotNil(t, servers, "servers was nil")
	require.Equal(t, 2, len(servers), "wrong # of servers")

	return servers
}