| 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 |
| 11 "github.com/luci/luci-go/common/errors" | 11 "github.com/luci/luci-go/common/errors" |
| 12 ) | 12 ) |
| 13 | 13 |
| 14 type datastoreImpl struct{ RawInterface } | 14 type datastoreImpl struct{ RawInterface } |
| 15 | 15 |
| 16 var _ Interface = (*datastoreImpl)(nil) | 16 var _ Interface = (*datastoreImpl)(nil) |
| 17 | 17 |
| 18 func (d *datastoreImpl) KeyForObj(src interface{}) Key { | 18 func (d *datastoreImpl) KeyForObj(src interface{}) Key { |
| 19 ret, err := d.KeyForObjErr(src) | 19 ret, err := d.KeyForObjErr(src) |
| 20 if err != nil { | 20 if err != nil { |
| 21 panic(err) | 21 panic(err) |
| 22 } | 22 } |
| 23 return ret | 23 return ret |
| 24 } | 24 } |
| 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) { |
| 31 return d.RawInterface.DecodeCursor(s) |
| 32 } |
| 33 |
| 30 func (d *datastoreImpl) Run(q Query, cbIface interface{}) error { | 34 func (d *datastoreImpl) Run(q Query, cbIface interface{}) error { |
| 31 // TODO(riannucci): Profile and determine if any of this is causing a re
al | 35 // TODO(riannucci): Profile and determine if any of this is causing a re
al |
| 32 // slowdown. Could potentially cache reflection stuff by cbType? | 36 // slowdown. Could potentially cache reflection stuff by cbType? |
| 33 cbTyp := reflect.TypeOf(cbIface) | 37 cbTyp := reflect.TypeOf(cbIface) |
| 34 | 38 |
| 35 badSig := false | 39 badSig := false |
| 36 mat := multiArgType{} | 40 mat := multiArgType{} |
| 37 isKey := false | 41 isKey := false |
| 38 | 42 |
| 39 if cbTyp.Kind() == reflect.Func && cbTyp.NumIn() == 2 && cbTyp.NumOut()
== 1 { | 43 if cbTyp.Kind() == reflect.Func && cbTyp.NumIn() == 2 && cbTyp.NumOut()
== 1 { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 err = lme.Get() | 214 err = lme.Get() |
| 211 if err == nil { | 215 if err == nil { |
| 212 err = extErr | 216 err = extErr |
| 213 } | 217 } |
| 214 return | 218 return |
| 215 } | 219 } |
| 216 | 220 |
| 217 func (d *datastoreImpl) Raw() RawInterface { | 221 func (d *datastoreImpl) Raw() RawInterface { |
| 218 return d.RawInterface | 222 return d.RawInterface |
| 219 } | 223 } |
| OLD | NEW |