(ctx context.Context, service, method string, in, out proto.Message)
| 89 | } |
| 90 | |
| 91 | func Call(ctx context.Context, service, method string, in, out proto.Message) error { |
| 92 | if ns := NamespaceFromContext(ctx); ns != "" { |
| 93 | if fn, ok := NamespaceMods[service]; ok { |
| 94 | fn(in, ns) |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | if f, ctx, ok := callOverrideFromContext(ctx); ok { |
| 99 | return f(ctx, service, method, in, out) |
| 100 | } |
| 101 | |
| 102 | // Handle already-done contexts quickly. |
| 103 | select { |
| 104 | case <-ctx.Done(): |
| 105 | return ctx.Err() |
| 106 | default: |
| 107 | } |
| 108 | |
| 109 | c := fromContext(ctx) |
| 110 | if c == nil { |
| 111 | // Give a good error message rather than a panic lower down. |
| 112 | return errNotAppEngineContext |
| 113 | } |
| 114 | |
| 115 | // Apply transaction modifications if we're in a transaction. |
| 116 | if t := transactionFromContext(ctx); t != nil { |
| 117 | if t.finished { |
| 118 | return errors.New("transaction context has expired") |
| 119 | } |
| 120 | applyTransaction(in, &t.transaction) |
| 121 | } |
| 122 | |
| 123 | var opts *appengine_internal.CallOptions |
| 124 | if d, ok := ctx.Deadline(); ok { |
| 125 | opts = &appengine_internal.CallOptions{ |
| 126 | Timeout: d.Sub(time.Now()), |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | err := c.Call(service, method, in, out, opts) |
| 131 | switch v := err.(type) { |
| 132 | case *appengine_internal.APIError: |
| 133 | return &APIError{ |
| 134 | Service: v.Service, |
| 135 | Detail: v.Detail, |
| 136 | Code: v.Code, |
| 137 | } |
| 138 | case *appengine_internal.CallError: |
| 139 | return &CallError{ |
| 140 | Detail: v.Detail, |
| 141 | Code: v.Code, |
| 142 | Timeout: v.Timeout, |
| 143 | } |
| 144 | } |
| 145 | return err |
| 146 | } |
| 147 | |
| 148 | func Middleware(next http.Handler) http.Handler { |
nothing calls this directly
no test coverage detected
searching dependent graphs…