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

Closed
hb-chen opened this issue Nov 30, 2019 · 3 comments
Closed

api handler need support SelectOption #1003

hb-chen opened this issue Nov 30, 2019 · 3 comments
Labels
question RPC RPC related issue

Comments

@hb-chen
Copy link
Contributor

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
Copy link

skw0823 commented Dec 2, 2019

I have the same problem

@asim
Copy link
Collaborator

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.

@milosgajdos milosgajdos added question RPC RPC related issue labels Dec 2, 2019
@vtolstov
Copy link
Contributor

vtolstov commented Feb 1, 2020

@asim can you suggest next steps for this? I'm need to use own selector for rpc handler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question RPC RPC related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants