Example #1
0
func (staticResolver) Resolve(name string) (*discovery.Service, error) {
	insts := []discovery.Instance{
		discovery.NewInstance("memory:///", nil),
	}
	svc := &discovery.Service{
		Name:      name,
		Instances: insts,
	}

	return svc, nil
}
Example #2
0
func (s *Server) announce(an discovery.Announcer) error {
	addr, ok := s.proto.Transport().(transport.Addresser)
	if !ok {
		return errors.New("can only announce transport of type transport.Addresser")
	}

	for _, name := range s.mux.Names() {
		instance := discovery.NewInstance(addr.Addr(), s.metas[name])
		err := an.Announce(name, instance)
		if err != nil {
			return err
		}
	}
	return nil
}