make grpc proxy streaming work
This commit is contained in:
parent
225b17559b
commit
9cecf2e097
@ -398,7 +398,7 @@ func (p *Proxy) ServeRequest(ctx context.Context, req server.Request, rsp server
|
||||
|
||||
// set address if available via routes or specific endpoint
|
||||
if len(routes) > 0 {
|
||||
addresses := toNodes(routes)
|
||||
addresses = toNodes(routes)
|
||||
opts = append(opts, client.WithAddress(addresses...))
|
||||
}
|
||||
|
||||
@ -489,6 +489,25 @@ func (p *Proxy) serveRequest(ctx context.Context, link client.Client, service, e
|
||||
}
|
||||
defer stream.Close()
|
||||
|
||||
// if we receive a grpc stream we have to refire the initial request
|
||||
if c, ok := req.Codec().(codec.Codec); ok && c.String() == "grpc" {
|
||||
// get the header from client
|
||||
hdr := req.Header()
|
||||
msg := &codec.Message{
|
||||
Type: codec.Request,
|
||||
Header: hdr,
|
||||
Body: body,
|
||||
}
|
||||
|
||||
// write the raw request
|
||||
err = stream.Request().Codec().Write(msg, nil)
|
||||
if err == io.EOF {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// create client request read loop if streaming
|
||||
go readLoop(req, stream)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user