(
ctx context.Context,
node *registry.Node,
req Request,
resp interface{},
opts CallOptions,
)
| 77 | } |
| 78 | |
| 79 | func (r *rpcClient) call( |
| 80 | ctx context.Context, |
| 81 | node *registry.Node, |
| 82 | req Request, |
| 83 | resp interface{}, |
| 84 | opts CallOptions, |
| 85 | ) error { |
| 86 | address := node.Address |
| 87 | logger := r.Options().Logger |
| 88 | |
| 89 | msg := &transport.Message{ |
| 90 | Header: make(map[string]string), |
| 91 | } |
| 92 | |
| 93 | md, ok := metadata.FromContext(ctx) |
| 94 | if ok { |
| 95 | for k, v := range md { |
| 96 | // Don't copy Micro-Topic header, that is used for pub/sub |
| 97 | // this is fixes the case when the client uses the same context that |
| 98 | // is received in the subscriber. |
| 99 | if k == headers.Message { |
| 100 | continue |
| 101 | } |
| 102 | |
| 103 | msg.Header[k] = v |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | // Set connection timeout for single requests to the server. Should be > 0 |
| 108 | // as otherwise requests can't be made. |
| 109 | cTimeout := opts.ConnectionTimeout |
| 110 | if cTimeout == 0 { |
| 111 | logger.Log(log.DebugLevel, "connection timeout was set to 0, overridng to default connection timeout") |
| 112 | |
| 113 | cTimeout = DefaultConnectionTimeout |
| 114 | } |
| 115 | |
| 116 | // set timeout in nanoseconds |
| 117 | msg.Header["Timeout"] = fmt.Sprintf("%d", cTimeout) |
| 118 | // set the content type for the request |
| 119 | msg.Header["Content-Type"] = req.ContentType() |
| 120 | // set the accept header |
| 121 | msg.Header["Accept"] = req.ContentType() |
| 122 | |
| 123 | // setup old protocol |
| 124 | reqCodec := setupProtocol(msg, node) |
| 125 | |
| 126 | // no codec specified |
| 127 | if reqCodec == nil { |
| 128 | var err error |
| 129 | reqCodec, err = r.newCodec(req.ContentType()) |
| 130 | |
| 131 | if err != nil { |
| 132 | return merrors.InternalServerError("go.micro.client", err.Error()) |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | dOpts := []transport.DialOption{ |
nothing calls this directly
no test coverage detected