feat: mapreduce generic version (#2827)

* feat: mapreduce generic version

* fix: gateway mr type issue

---------

Co-authored-by: kevin.wan <kevin.wan@yijinin.com>
This commit is contained in:
Kevin Wan
2023-01-29 18:01:23 +08:00
committed by GitHub
parent 413ee919e6
commit 464ed51728
8 changed files with 166 additions and 193 deletions

View File

@@ -63,12 +63,11 @@ func (s *Server) build() error {
return err
}
return mr.MapReduceVoid(func(source chan<- any) {
return mr.MapReduceVoid(func(source chan<- Upstream) {
for _, up := range s.upstreams {
source <- up
}
}, func(item any, writer mr.Writer, cancel func(error)) {
up := item.(Upstream)
}, func(up Upstream, writer mr.Writer[rest.Route], cancel func(error)) {
cli := zrpc.MustNewClient(up.Grpc)
source, err := s.createDescriptorSource(cli, up)
if err != nil {
@@ -109,9 +108,8 @@ func (s *Server) build() error {
Handler: s.buildHandler(source, resolver, cli, m.RpcPath),
})
}
}, func(pipe <-chan any, cancel func(error)) {
for item := range pipe {
route := item.(rest.Route)
}, func(pipe <-chan rest.Route, cancel func(error)) {
for route := range pipe {
s.Server.AddRoute(route)
}
})