Go-micro: api handler need support SelectOption

Created on 30 Nov 2019  路  3Comments  路  Source: asim/go-micro

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?

RPC question

Most helpful comment

I have the same problem

All 3 comments

I have the same problem

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.

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

Was this page helpful?
0 / 5 - 0 ratings