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

Side by Side Diff: impl/prod/raw_datastore.go

Issue 1309933003: datastore: Add DecodeCursor to [Raw]Interface. (Closed) Base URL: https://github.com/luci/gae@master
Patch Set: Use more concise formulation. 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
« no previous file with comments | « impl/memory/datastore_query.go ('k') | service/datastore/datastore.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 package prod 5 package prod
6 6
7 import ( 7 import (
8 ds "github.com/luci/gae/service/datastore" 8 ds "github.com/luci/gae/service/datastore"
9 "github.com/luci/gae/service/info" 9 "github.com/luci/gae/service/info"
10 "golang.org/x/net/context" 10 "golang.org/x/net/context"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 k = dsR2F(rkeys[idx]) 124 k = dsR2F(rkeys[idx])
125 } 125 }
126 cb(k, err) 126 cb(k, err)
127 }) 127 })
128 } 128 }
129 129
130 func (d rdsImpl) NewQuery(kind string) ds.Query { 130 func (d rdsImpl) NewQuery(kind string) ds.Query {
131 return queryImpl{datastore.NewQuery(kind)} 131 return queryImpl{datastore.NewQuery(kind)}
132 } 132 }
133 133
134 func (d rdsImpl) DecodeCursor(s string) (ds.Cursor, error) {
135 return datastore.DecodeCursor(s)
136 }
137
134 func (d rdsImpl) Run(q ds.Query, cb ds.RawRunCB) error { 138 func (d rdsImpl) Run(q ds.Query, cb ds.RawRunCB) error {
135 tf := typeFilter{} 139 tf := typeFilter{}
136 t := q.(queryImpl).Query.Run(d) 140 t := q.(queryImpl).Query.Run(d)
137 cfunc := func() (ds.Cursor, error) { 141 cfunc := func() (ds.Cursor, error) {
138 return t.Cursor() 142 return t.Cursor()
139 } 143 }
140 for { 144 for {
141 k, err := t.Next(&tf) 145 k, err := t.Next(&tf)
142 if err == datastore.Done { 146 if err == datastore.Done {
143 return nil 147 return nil
144 } 148 }
145 if err != nil { 149 if err != nil {
146 return err 150 return err
147 } 151 }
148 if !cb(dsR2F(k), tf.pm, cfunc) { 152 if !cb(dsR2F(k), tf.pm, cfunc) {
149 return nil 153 return nil
150 } 154 }
151 } 155 }
152 } 156 }
153 157
154 func (d rdsImpl) RunInTransaction(f func(c context.Context) error, opts *ds.Tran sactionOptions) error { 158 func (d rdsImpl) RunInTransaction(f func(c context.Context) error, opts *ds.Tran sactionOptions) error {
155 ropts := (*datastore.TransactionOptions)(opts) 159 ropts := (*datastore.TransactionOptions)(opts)
156 return datastore.RunInTransaction(d, f, ropts) 160 return datastore.RunInTransaction(d, f, ropts)
157 } 161 }
158 162
159 func (d rdsImpl) Testable() ds.Testable { 163 func (d rdsImpl) Testable() ds.Testable {
160 return nil 164 return nil
161 } 165 }
OLDNEW
« no previous file with comments | « impl/memory/datastore_query.go ('k') | service/datastore/datastore.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698