OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package datastore | 5 package datastore |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "reflect" | 9 "reflect" |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 func (d *datastoreImpl) KeyForObjErr(src interface{}) (Key, error) { | 26 func (d *datastoreImpl) KeyForObjErr(src interface{}) (Key, error) { |
27 return newKeyObjErr(d.NewKey, src) | 27 return newKeyObjErr(d.NewKey, src) |
28 } | 28 } |
29 | 29 |
30 func (d *datastoreImpl) DecodeCursor(s string) (Cursor, error) { | 30 func (d *datastoreImpl) DecodeCursor(s string) (Cursor, error) { |
31 return d.RawInterface.DecodeCursor(s) | 31 return d.RawInterface.DecodeCursor(s) |
32 } | 32 } |
33 | 33 |
34 func (d *datastoreImpl) Run(q Query, cbIface interface{}) error { | 34 func (d *datastoreImpl) Run(q Query, cbIface interface{}) error { |
| 35 if cbIface == nil { |
| 36 return fmt.Errorf("cannot use nil callback when Running query") |
| 37 } |
| 38 |
35 // TODO(riannucci): Profile and determine if any of this is causing a re
al | 39 // TODO(riannucci): Profile and determine if any of this is causing a re
al |
36 // slowdown. Could potentially cache reflection stuff by cbType? | 40 // slowdown. Could potentially cache reflection stuff by cbType? |
37 cbTyp := reflect.TypeOf(cbIface) | 41 cbTyp := reflect.TypeOf(cbIface) |
38 | 42 |
39 badSig := false | 43 badSig := false |
40 mat := multiArgType{} | 44 mat := multiArgType{} |
41 isKey := false | 45 isKey := false |
42 | 46 |
43 if cbTyp.Kind() == reflect.Func && cbTyp.NumIn() == 2 && cbTyp.NumOut()
== 1 { | 47 if cbTyp.Kind() == reflect.Func && cbTyp.NumIn() == 2 && cbTyp.NumOut()
== 1 { |
44 firstArg := cbTyp.In(0) | 48 firstArg := cbTyp.In(0) |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 err = lme.Get() | 218 err = lme.Get() |
215 if err == nil { | 219 if err == nil { |
216 err = extErr | 220 err = extErr |
217 } | 221 } |
218 return | 222 return |
219 } | 223 } |
220 | 224 |
221 func (d *datastoreImpl) Raw() RawInterface { | 225 func (d *datastoreImpl) Raw() RawInterface { |
222 return d.RawInterface | 226 return d.RawInterface |
223 } | 227 } |
OLD | NEW |