-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathstore.go
44 lines (38 loc) · 1.28 KB
/
store.go
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
/*
Kasper companion library for stateful stream processing.
*/
package kasper
// TenantKey is a pair of tenant and key.
// Used by MultiStore.GetAll
type TenantKey struct {
Tenant string
Key string
}
// Store is a universal interface for a key-value store.
// Keys are strings, and values are byte slices.
type Store interface {
// Get gets a value by key.
Get(key string) ([]byte, error)
// GetAll gets multiple values by key.
GetAll(keys []string) (map[string][]byte, error)
// Put insert or update a value by key.
Put(key string, value []byte) error
// PutAll inserts or updates multiple key-value pairs.
PutAll(map[string][]byte) error
// Delete deletes a key from the store.
Delete(key string) error
// Flush indicates that the underlying storage must be made persistent.
Flush() error
}
// MultiStore is a multitenant version of Store.
// Tenants are represented as strings. Each tenant has an underlying Store.
type MultiStore interface {
// Tenant returns the underlying store for a tenant.
Tenant(tenant string) Store
// AllTenants returns the list of known tenants to this instance.
AllTenants() []string
// Fetch is a multitenant version of GetAll.
Fetch(keys []TenantKey) (*MultiMap, error)
// Push is a multitenant version of PutAll
Push(store *MultiMap) error
}