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

Function Call

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

Source from the content-addressed store, hash-verified

89}
90
91func 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
148func Middleware(next http.Handler) http.Handler {

Callers

nothing calls this directly

Calls 9

NamespaceFromContextFunction · 0.70
callOverrideFromContextFunction · 0.70
fromContextFunction · 0.70
transactionFromContextFunction · 0.70
applyTransactionFunction · 0.70
DoneMethod · 0.45
ErrMethod · 0.45
DeadlineMethod · 0.45
CallMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…