(ctx context.Context, service, method string, in, out proto.Message)
| 423 | } |
| 424 | |
| 425 | func 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) |
searching dependent graphs…