Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api handler need support SelectOption #1003

Open
hb-chen opened this issue Nov 30, 2019 · 2 comments
Open

api handler need support SelectOption #1003

hb-chen opened this issue Nov 30, 2019 · 2 comments
Labels

Comments

@hb-chen
Copy link
Contributor

@hb-chen hb-chen commented Nov 30, 2019

Is your feature request related to a problem? Please describe.
I want filter go.micro.api.xxx service. So I custom micro main() func.

func main() {
	cmd.Init(
		micro.WrapClient(xxx.NewClientWrapper()),
	)
}

xxx client wrapper add CallOption

client.WithSelectOption(selector.WithFilter(MyFilterFunc()))

But when I build and run micro, filter work, but service not filtered...😂

Then I see api and rpc handler use a strategy() func.
ignore input to this function, use services above

// strategy is a hack for selection
func strategy(services []*registry.Service) selector.Strategy {
	return func(_ []*registry.Service) selector.Next {
		// ignore input to this function, use services above
		return selector.Random(services)
	}
}
// create strategy
so := selector.WithStrategy(strategy(service.Services))
if err := c.Call(cx, req, rsp, client.WithSelectOption(so)); err != nil {
}

Describe the solution you'd like
I try to remove the strategy, then build and run micro, it's ok. But I don't know if it will cause other problems.
Can we remove the strategy, or why use like this?
Or any other better ways?

@skw0823

This comment has been minimized.

Copy link

@skw0823 skw0823 commented Dec 2, 2019

I have the same problem

@asim

This comment has been minimized.

Copy link
Member

@asim asim commented Dec 2, 2019

It's like this because the api is building routing information from the registry for a set of endpoints. Its then using that cache rather than requerying for new nodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.