@@ -31,6 +31,12 @@ proper error reporting. Thus, all Datastore calls may return errors, which
31
31
should be checked by callers.
32
32
*/
33
33
type Datastore interface {
34
+ Read
35
+ Write
36
+ }
37
+
38
+ // Write is the write-side of the Datastore interface.
39
+ type Write interface {
34
40
// Put stores the object `value` named by `key`.
35
41
//
36
42
// The generalized Datastore interface does not impose a value type,
@@ -42,6 +48,12 @@ type Datastore interface {
42
48
// type-safe interface to your application, and do the checking up-front.
43
49
Put (key Key , value []byte ) error
44
50
51
+ // Delete removes the value for given `key`.
52
+ Delete (key Key ) error
53
+ }
54
+
55
+ // Read is the read-side of the Datastore interface.
56
+ type Read interface {
45
57
// Get retrieves the object `value` named by `key`.
46
58
// Get will return ErrNotFound if the key is not mapped to a value.
47
59
Get (key Key ) (value []byte , err error )
@@ -57,9 +69,6 @@ type Datastore interface {
57
69
// value rather than retrieving the value itself.
58
70
GetSize (key Key ) (size int , err error )
59
71
60
- // Delete removes the value for given `key`.
61
- Delete (key Key ) error
62
-
63
72
// Query searches the datastore and returns a query result. This function
64
73
// may return before the query actually runs. To wait for the query:
65
74
//
@@ -87,6 +96,8 @@ type Batching interface {
87
96
Batch () (Batch , error )
88
97
}
89
98
99
+ // ErrBatchUnsupported is returned if the by Batch if the Datastore doesn't
100
+ // actually support batching.
90
101
var ErrBatchUnsupported = errors .New ("this datastore does not support batching" )
91
102
92
103
// ThreadSafeDatastore is an interface that all threadsafe datastore should
@@ -223,9 +234,7 @@ func GetBackedSize(ds Datastore, key Key) (int, error) {
223
234
}
224
235
225
236
type Batch interface {
226
- Put (key Key , val []byte ) error
227
-
228
- Delete (key Key ) error
237
+ Write
229
238
230
239
Commit () error
231
240
}
0 commit comments