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

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

Issue 1259593005: Add 'user friendly' datastore API. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: 100% coverage of new code Created 5 years, 4 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package rawdatastore
6
7 import (
8 "reflect"
9 )
10
11 // GetPLS resolves o into a PropertyLoadSaver. o must be a pointer to a
12 // struct of some sort.
13 func GetPLS(o interface{}) PropertyLoadSaver {
14 v := reflect.ValueOf(o)
15 if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct {
16 return &structPLS{c: &structCodec{problem: ErrInvalidEntityType} }
17 }
18 v = v.Elem()
19 t := v.Type()
20
21 structCodecsMutex.RLock()
22 if c, ok := structCodecs[t]; ok {
23 structCodecsMutex.RUnlock()
24 return &structPLS{v, c}
25 }
26 structCodecsMutex.RUnlock()
27
28 structCodecsMutex.Lock()
29 defer structCodecsMutex.Unlock()
30 return &structPLS{v, getStructCodecLocked(t)}
31 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698