MCPcopy
hub / github.com/micro/go-micro / call

Method call

client/rpc_client.go:79–234  ·  view source on GitHub ↗
(
	ctx context.Context,
	node *registry.Node,
	req Request,
	resp interface{},
	opts CallOptions,
)

Source from the content-addressed store, hash-verified

77}
78
79func (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{

Callers

nothing calls this directly

Calls 15

OptionsMethod · 0.95
newCodecMethod · 0.95
CloseMethod · 0.95
SendMethod · 0.95
RecvMethod · 0.95
FromContextFunction · 0.92
LogFunction · 0.92
WithStreamFunction · 0.92
WithTimeoutFunction · 0.92
WithConnCloseFunction · 0.92
setupProtocolFunction · 0.70
newRPCCodecFunction · 0.70

Tested by

no test coverage detected