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

Function registerFunction

v2/delay/delay.go:184–212  ·  view source on GitHub ↗
(key string, i interface{})

Source from the content-addressed store, hash-verified

182}
183
184func registerFunction(key string, i interface{}) (*Function, error) {
185 f := &Function{fv: reflect.ValueOf(i)}
186 f.key = key
187
188 t := f.fv.Type()
189 if t.Kind() != reflect.Func {
190 f.err = errors.New("not a function")
191 return f, f.err
192 }
193 if t.NumIn() == 0 || !isContext(t.In(0)) {
194 f.err = errFirstArg
195 return f, errFirstArg
196 }
197
198 // Register the function's arguments with the gob package.
199 // This is required because they are marshaled inside a []interface{}.
200 // gob.Register only expects to be called during initialization;
201 // that's fine because this function expects the same.
202 for i := 0; i < t.NumIn(); i++ {
203 // Only concrete types may be registered. If the argument has
204 // interface type, the client is resposible for registering the
205 // concrete types it will hold.
206 if t.In(i).Kind() == reflect.Interface {
207 continue
208 }
209 gob.Register(reflect.Zero(t.In(i)).Interface())
210 }
211 return f, nil
212}
213
214type invocation struct {
215 Key string

Callers 2

FuncFunction · 0.85
MustRegisterFunction · 0.85

Calls 3

isContextFunction · 0.70
TypeMethod · 0.45
KindMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…