MCPcopy Create free account
hub / github.com/paypal/junodb / ProcessRequest

Method ProcessRequest

internal/cli/processor.go:263–303  ·  view source on GitHub ↗
(request *proto.OperationalMessage)

Source from the content-addressed store, hash-verified

261}
262
263func (c *Processor) ProcessRequest(request *proto.OperationalMessage) (resp *proto.OperationalMessage, err error) {
264 timeStart := time.Now()
265
266 ch, err := c.send(request)
267 if err == nil {
268 if r, ok := <-ch; ok {
269 resp = r.GetResponse()
270 err = r.GetError()
271 } else {
272 resp = nil
273 err = fmt.Errorf("response channel closed by request processor")
274 }
275 }
276
277 if err != nil && !specialError(err) {
278 err = &IOError{err}
279 }
280 if cal.IsEnabled() {
281 var txnType string
282 if c.server.SSLEnabled {
283 txnType = kCalSslTxnType
284 } else {
285 txnType = kCalTxnType
286 }
287 rht := time.Since(timeStart)
288
289 if err == nil {
290 status := resp.GetOpStatus()
291 b := logging.NewKVBuffer()
292 b.AddOpRequestResponseInfo(request, resp)
293 cal.AtomicTransaction(txnType, request.GetOpCode().String(), logging.CalStatus(status).CalStatus(), rht, b.Bytes())
294 } else {
295 tail := fmt.Sprintf("raddr=%s&res_timeout=%dms&ns=%s&%s", c.server.Addr,
296 c.responseTimeout.Nanoseconds()/int64(1e6), request.GetNamespace(), err.Error())
297 cal.AtomicTransaction(txnType, request.GetOpCode().String(),
298 cal.StatusError, rht, []byte(tail)) ///TODO to change: data to cal
299 }
300 }
301
302 return
303}
304
305func (c *Processor) ProcessBatchRequests(requests []*proto.OperationalMessage) (responses []*proto.OperationalMessage, err error) {
306 numRequests := len(requests)

Callers 15

IsUpMethod · 0.95
CreateMethod · 0.80
GetMethod · 0.80
UpdateMethod · 0.80
SetMethod · 0.80
DestroyMethod · 0.80
UDFGetMethod · 0.80
UDFSetMethod · 0.80
ExecMethod · 0.80
ExecMethod · 0.80
ExecMethod · 0.80
ExecMethod · 0.80

Calls 15

sendMethod · 0.95
IsEnabledFunction · 0.92
NewKVBufferFunction · 0.92
AtomicTransactionFunction · 0.92
CalStatusFunction · 0.92
specialErrorFunction · 0.85
CalStatusMethod · 0.80
GetResponseMethod · 0.65
GetErrorMethod · 0.65
StringMethod · 0.65
GetOpCodeMethod · 0.65

Tested by

no test coverage detected