MCPcopy Create free account
hub / github.com/golang/appengine / Call

Function Call

internal/api.go:425–517  ·  view source on GitHub ↗
(ctx context.Context, service, method string, in, out proto.Message)

Source from the content-addressed store, hash-verified

423}
424
425func Call(ctx context.Context, service, method string, in, out proto.Message) error {
426 if ns := NamespaceFromContext(ctx); ns != "" {
427 if fn, ok := NamespaceMods[service]; ok {
428 fn(in, ns)
429 }
430 }
431
432 if f, ctx, ok := callOverrideFromContext(ctx); ok {
433 return f(ctx, service, method, in, out)
434 }
435
436 // Handle already-done contexts quickly.
437 select {
438 case <-ctx.Done():
439 return ctx.Err()
440 default:
441 }
442
443 c := fromContext(ctx)
444
445 // Apply transaction modifications if we're in a transaction.
446 if t := transactionFromContext(ctx); t != nil {
447 if t.finished {
448 return errors.New("transaction aeContext has expired")
449 }
450 applyTransaction(in, &t.transaction)
451 }
452
453 // Default RPC timeout is 60s.
454 timeout := 60 * time.Second
455 if deadline, ok := ctx.Deadline(); ok {
456 timeout = deadline.Sub(time.Now())
457 }
458
459 data, err := proto.Marshal(in)
460 if err != nil {
461 return err
462 }
463
464 ticket := ""
465 if c != nil {
466 ticket = c.req.Header.Get(ticketHeader)
467 if dri := c.req.Header.Get(devRequestIdHeader); IsDevAppServer() && dri != "" {
468 ticket = dri
469 }
470 }
471 req := &remotepb.Request{
472 ServiceName: &service,
473 Method: &method,
474 Request: data,
475 RequestId: &ticket,
476 }
477 hreqBody, err := proto.Marshal(req)
478 if err != nil {
479 return err
480 }
481
482 hrespBody, err := post(ctx, hreqBody, timeout)

Callers 15

ModuleHostnameFunction · 0.92
AccessTokenFunction · 0.92
PublicCertificatesFunction · 0.92
ServiceAccountFunction · 0.92
SignBytesFunction · 0.92
APICallFunction · 0.92
handleFunction · 0.92
RoundTripMethod · 0.92
ServingURLFunction · 0.92
DeleteServingURLFunction · 0.92
CountMethod · 0.92
callNextFunction · 0.92

Calls 14

MarshalMethod · 0.80
UnmarshalMethod · 0.80
NamespaceFromContextFunction · 0.70
callOverrideFromContextFunction · 0.70
fromContextFunction · 0.70
transactionFromContextFunction · 0.70
applyTransactionFunction · 0.70
IsDevAppServerFunction · 0.70
postFunction · 0.70
DoneMethod · 0.45
ErrMethod · 0.45
DeadlineMethod · 0.45

Tested by 6

TestDialLimitFunction · 0.56
TestAPICallFunction · 0.56
TestAPICallRPCFailureFunction · 0.56
TestAPICallDialFailureFunction · 0.56
TestAPICallAllocationsFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…