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

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

Issue 2011773002: datastore: variadic Get, Put, Exists, Delete. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Created 4 years, 7 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
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 "golang.org/x/net/context" 8 "golang.org/x/net/context"
9 ) 9 )
10 10
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // Does a Get for this key and returns true iff it exists. Will only ret urn 161 // Does a Get for this key and returns true iff it exists. Will only ret urn
162 // an error if it's not ErrNoSuchEntity. This is slightly more efficient 162 // an error if it's not ErrNoSuchEntity. This is slightly more efficient
163 // than using Get directly, because it uses the underlying RawInterface to 163 // than using Get directly, because it uses the underlying RawInterface to
164 // avoid some reflection and copies. 164 // avoid some reflection and copies.
165 Exists(k *Key) (bool, error) 165 Exists(k *Key) (bool, error)
166 166
167 // Does a GetMulti for thes keys and returns true iff they exist. Will o nly 167 // Does a GetMulti for thes keys and returns true iff they exist. Will o nly
168 // return an error if it's not ErrNoSuchEntity. This is slightly more ef ficient 168 // return an error if it's not ErrNoSuchEntity. This is slightly more ef ficient
169 // than using Get directly, because it uses the underlying RawInterface to 169 // than using Get directly, because it uses the underlying RawInterface to
170 // avoid some reflection and copies. 170 // avoid some reflection and copies.
171 » ExistsMulti(k []*Key) (BoolList, error) 171 » //
172 » // If an error is encountered, the returned error will be a MultiError w hose
173 » // error index corresponds to the key for which the error was encountere d.
174 » ExistsMulti(k ...*Key) (BoolList, error)
172 175
173 » // Get retrieves a single object from the datastore 176 » // Get retrieves objects from the datastore.
174 // 177 //
175 » // dst must be one of: 178 » // Each element in dst must be one of:
176 » // - *S where S is a struct 179 » //» - *S where S is a struct
177 » // - *P where *P is a concrete type implementing PropertyLoadSaver 180 » //» - *P where *P is a concrete type implementing PropertyLoadSaver
178 » Get(dst interface{}) error 181 » //» - []S or []*S where S is a struct
179 182 » //» - []P or []*P where *P is a concrete type implementing PropertyL oadSaver
180 » // Put inserts a single object into the datastore 183 » //» - []I where I is some interface type. Each element of the slice must
184 » //» be non-nil, and its underlying type must be either *S or *P.
181 // 185 //
182 » // src must be one of: 186 » // If an error is encountered, the returned error value will depend on t he
183 » // - *S where S is a struct 187 » // input arguments. If one argument is supplied, the result will be the
184 » // - *P where *P is a concrete type implementing PropertyLoadSaver 188 » // encountered error type. If multiple arguments are supplied, the resul t will
189 » // be a MultiError whose error index corresponds to the argument in whic h the
190 » // error was encountered.
185 // 191 //
186 » // A *Key will be extracted from src via KeyForObj. If 192 » // If a dst argument is a slice, its error type will be a MultiError. No te
187 » // extractedKey.Incomplete() is true, then Put will write the resolved ( i.e. 193 » // that in the scenario where multiple slices are provided, this will re turn a
188 » // automatic datastore-populated) *Key back to src. 194 » // return a MultiError containing a nexted MultiError for each slice arg ument.
189 » Put(src interface{}) error 195 » Get(dst ...interface{}) error
190
191 » // Delete removes an item from the datastore.
192 » Delete(key *Key) error
193 196
194 // GetMulti retrieves items from the datastore. 197 // GetMulti retrieves items from the datastore.
195 // 198 //
196 // dst must be one of: 199 // dst must be one of:
197 // - []S or []*S where S is a struct 200 // - []S or []*S where S is a struct
198 // - []P or []*P where *P is a concrete type implementing PropertyLoad Saver 201 // - []P or []*P where *P is a concrete type implementing PropertyLoad Saver
199 // - []I where I is some interface type. Each element of the slice mus t 202 // - []I where I is some interface type. Each element of the slice mus t
200 // be non-nil, and its underlying type must be either *S or *P. 203 // be non-nil, and its underlying type must be either *S or *P.
204 //
205 // NOTE: GetMulti is obsolete. The vararg-accepting Get should be used
206 // instead. This is left for backwards compatibility, but will be remove d from
207 // this interface at some point in the future.
iannucci 2016/05/25 17:36:47 as in: right after this lands and we refactor luci
201 GetMulti(dst interface{}) error 208 GetMulti(dst interface{}) error
202 209
210 // Put inserts a single object into the datastore
211 //
212 // src must be one of:
213 // - *S where S is a struct
214 // - *P where *P is a concrete type implementing PropertyLoadSaver
215 // - []S or []*S where S is a struct
216 // - []P or []*P where *P is a concrete type implementing PropertyL oadSaver
217 // - []I where i is some interface type. Each elemet of the slice m ust
218 // be non-nil, and its underlying type must be either *S or *P.
219 //
220 // A *Key will be extracted from src via KeyForObj. If
221 // extractedKey.Incomplete() is true, then Put will write the resolved ( i.e.
222 // automatic datastore-populated) *Key back to src.
223 //
224 // If an error is encountered, the returned error value will depend on t he
225 // input arguments. If one argument is supplied, the result will be the
226 // encountered error type. If multiple arguments are supplied, the resul t will
227 // be a MultiError whose error index corresponds to the argument in whic h the
228 // error was encountered.
229 //
230 // If a src argument is a slice, its error type will be a MultiError. No te
231 // that in the scenario where multiple slices are provided, this will re turn a
232 // return a MultiError containing a nexted MultiError for each slice arg ument.
233 Put(src ...interface{}) error
234
203 // PutMulti writes items to the datastore. 235 // PutMulti writes items to the datastore.
204 // 236 //
205 // src must be one of: 237 // src must be one of:
206 » // - []S or []*S where S is a struct 238 » //» - []S or []*S where S is a struct
207 » // - []P or []*P where *P is a concrete type implementing PropertyLoad Saver 239 » //» - []P or []*P where *P is a concrete type implementing PropertyL oadSaver
208 » // - []I where i is some interface type. Each elemet of the slice must 240 » //» - []I where i is some interface type. Each elemet of the slice m ust
209 » // be non-nil, and its underlying type must be either *S or *P. 241 » //» be non-nil, and its underlying type must be either *S or *P.
210 // 242 //
211 // If items in src resolve to Incomplete keys, PutMulti will write the 243 // If items in src resolve to Incomplete keys, PutMulti will write the
212 // resolved keys back to the items in src. 244 // resolved keys back to the items in src.
245 //
246 // NOTE: PutMulti is obsolete. The vararg-accepting Put should be used
247 // instead. This is left for backwards compatibility, but will be remove d from
248 // this interface at some point in the future.
213 PutMulti(src interface{}) error 249 PutMulti(src interface{}) error
214 250
251 // Delete removes the supplied keys from the datastore.
252 //
253 // If an error is encountered, the returned error value will depend on t he
254 // input arguments. If one argument is supplied, the result will be the
255 // encountered error type. If multiple arguments are supplied, the resul t will
256 // be a MultiError whose error index corresponds to the argument in whic h the
257 // error was encountered.
258 Delete(key *Key) error
259
215 // DeleteMulti removes items from the datastore. 260 // DeleteMulti removes items from the datastore.
216 » DeleteMulti(keys []*Key) error 261 » //
262 » // If an error is encountered, the returned error will be a MultiError w hose
263 » // error index corresponds to the key for which the error was encountere d.
264 » DeleteMulti(keys ...*Key) error
iannucci 2016/05/25 17:36:47 do you plan to reconcile the Delete interface with
217 265
218 // Testable returns the Testable interface for the implementation, or ni l if 266 // Testable returns the Testable interface for the implementation, or ni l if
219 // there is none. 267 // there is none.
220 Testable() Testable 268 Testable() Testable
221 269
222 // Raw returns the underlying RawInterface. The Interface and RawInterfa ce may 270 // Raw returns the underlying RawInterface. The Interface and RawInterfa ce may
223 // be used interchangably; there's no danger of interleaving access to t he 271 // be used interchangably; there's no danger of interleaving access to t he
224 // datastore via the two. 272 // datastore via the two.
225 Raw() RawInterface 273 Raw() RawInterface
226 } 274 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698