-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdata_store.go
More file actions
45 lines (35 loc) · 1.36 KB
/
data_store.go
File metadata and controls
45 lines (35 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package bloomsearch
import (
"context"
"io"
)
// DataStore is used to read and write the file from storage.
//
// filePointerBytes is the serialized file pointer that is passed to the DataStore to open the file for reading, and stored within the MetaStore.
// For example, for an S3DataStore, this might be a serialzed JSON object of the bucket and file key.
type DataStore interface {
// CreateFile creates a file for single-pass writing, returning the handle for writing and the file pointer bytes.
CreateFile(ctx context.Context) (io.WriteCloser, []byte, error)
// OpenFile opens a file for reading.
OpenFile(ctx context.Context, filePointerBytes []byte) (io.ReadSeekCloser, error)
// TombstoneFile marks a file as no longer referenced by metadata.
// Implementations decide when physical garbage collection occurs.
TombstoneFile(ctx context.Context, filePointerBytes []byte) error
}
// TESTING
type NullDataStore struct{}
type NullDataStoreFilePointer struct {
ID string
}
func (n *NullDataStore) OpenFile(ctx context.Context, filePointerBytes []byte) (io.ReadSeekCloser, error) {
return nil, nil
}
func (n *NullDataStore) CreateFile(ctx context.Context) (io.WriteCloser, []byte, error) {
return nil, nil, nil
}
func (n *NullDataStore) TombstoneFile(ctx context.Context, filePointerBytes []byte) error {
return nil
}
func init() {
var _ DataStore = &NullDataStore{}
}