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

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

Issue 1521823003: Clean up callback interfaces. (Closed) Base URL: https://github.com/luci/gae.git@extra
Patch Set: fixins Created 5 years 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/datastore/errors.go ('k') | service/datastore/propertytype_string.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 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // 89 //
90 // Note that the behavior of transactions may change depending on what f ilters 90 // Note that the behavior of transactions may change depending on what f ilters
91 // have been installed. It's possible that we'll end up implementing thi ngs 91 // have been installed. It's possible that we'll end up implementing thi ngs
92 // like nested/buffered transactions as filters. 92 // like nested/buffered transactions as filters.
93 RunInTransaction(f func(c context.Context) error, opts *TransactionOptio ns) error 93 RunInTransaction(f func(c context.Context) error, opts *TransactionOptio ns) error
94 94
95 // Run executes the given query, and calls `cb` for each successfully 95 // Run executes the given query, and calls `cb` for each successfully
96 // retrieved item. 96 // retrieved item.
97 // 97 //
98 // cb is a callback function whose signature is 98 // cb is a callback function whose signature is
99 » // func(obj TYPE, getCursor CursorCB) bool 99 » // func(obj TYPE[, getCursor CursorCB]) [error]
100 // 100 //
101 // Where TYPE is one of: 101 // Where TYPE is one of:
102 // - S or *S where S is a struct 102 // - S or *S where S is a struct
103 // - P or *P where *P is a concrete type implementing PropertyLoadSave r 103 // - P or *P where *P is a concrete type implementing PropertyLoadSave r
104 // - *Key (implies a keys-only query) 104 // - *Key (implies a keys-only query)
105 // 105 //
106 » // Run stops on the first error encountered. 106 » // If the error is omitted from the signature, this will run until the q uery
107 » // returns all its results, or has an error/times out.
108 » //
109 » // If error is in the signature, the query will continue as long as the
110 » // callback returns nil. If it returns `Stop`, the query will stop and R un
111 » // will return nil. Otherwise, the query will stop and Run will return t he
112 » // user's error.
113 » //
114 » // Run may also stop on the first datastore error encountered, which can occur
115 » // due to flakiness, timeout, etc. If it encounters such an error, it wi ll
116 » // be returned.
107 Run(q *Query, cb interface{}) error 117 Run(q *Query, cb interface{}) error
108 118
109 // Count executes the given query and returns the number of entries whic h 119 // Count executes the given query and returns the number of entries whic h
110 // match it. 120 // match it.
111 Count(q *Query) (int64, error) 121 Count(q *Query) (int64, error)
112 122
113 // DecodeCursor converts a string returned by a Cursor into a Cursor ins tance. 123 // DecodeCursor converts a string returned by a Cursor into a Cursor ins tance.
114 // It will return an error if the supplied string is not valid, or could not 124 // It will return an error if the supplied string is not valid, or could not
115 // be decoded by the implementation. 125 // be decoded by the implementation.
116 DecodeCursor(string) (Cursor, error) 126 DecodeCursor(string) (Cursor, error)
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 193
184 // Testable returns the Testable interface for the implementation, or ni l if 194 // Testable returns the Testable interface for the implementation, or ni l if
185 // there is none. 195 // there is none.
186 Testable() Testable 196 Testable() Testable
187 197
188 // Raw returns the underlying RawInterface. The Interface and RawInterfa ce may 198 // Raw returns the underlying RawInterface. The Interface and RawInterfa ce may
189 // be used interchangably; there's no danger of interleaving access to t he 199 // be used interchangably; there's no danger of interleaving access to t he
190 // datastore via the two. 200 // datastore via the two.
191 Raw() RawInterface 201 Raw() RawInterface
192 } 202 }
OLDNEW
« no previous file with comments | « service/datastore/errors.go ('k') | service/datastore/propertytype_string.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698