Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: service/rawdatastore/datastore.go

Issue 1243323002: Refactor a bit. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix golint Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « service/rawdatastore/context_test.go ('k') | service/rawdatastore/datastore_impl.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // HEAVILY adapted from github.com/golang/appengine/datastore 5 package rawdatastore
6
7 package helper
8 6
9 import ( 7 import (
10 "reflect" 8 "reflect"
11
12 "github.com/luci/gae"
13 ) 9 )
14 10
15 // GetPLS resolves o into a gae.DSStructPLS. o must be a pointer to a 11 // GetPLS resolves o into a PropertyLoadSaver. o must be a pointer to a
16 // struct of some sort. 12 // struct of some sort.
17 func GetPLS(o interface{}) gae.DSPropertyLoadSaver { 13 func GetPLS(o interface{}) PropertyLoadSaver {
18 v := reflect.ValueOf(o) 14 v := reflect.ValueOf(o)
19 if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct { 15 if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct {
20 » » return &structPLS{c: &structCodec{problem: gae.ErrDSInvalidEntit yType}} 16 » » return &structPLS{c: &structCodec{problem: ErrInvalidEntityType} }
21 } 17 }
22 v = v.Elem() 18 v = v.Elem()
23 t := v.Type() 19 t := v.Type()
24 20
25 structCodecsMutex.RLock() 21 structCodecsMutex.RLock()
26 if c, ok := structCodecs[t]; ok { 22 if c, ok := structCodecs[t]; ok {
27 structCodecsMutex.RUnlock() 23 structCodecsMutex.RUnlock()
28 return &structPLS{v, c} 24 return &structPLS{v, c}
29 } 25 }
30 structCodecsMutex.RUnlock() 26 structCodecsMutex.RUnlock()
31 27
32 structCodecsMutex.Lock() 28 structCodecsMutex.Lock()
33 defer structCodecsMutex.Unlock() 29 defer structCodecsMutex.Unlock()
34 return &structPLS{v, getStructCodecLocked(t)} 30 return &structPLS{v, getStructCodecLocked(t)}
35 } 31 }
OLDNEW
« no previous file with comments | « service/rawdatastore/context_test.go ('k') | service/rawdatastore/datastore_impl.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698