Change store.Sync to store.List

This commit is contained in:
Asim Aslam
2019-10-23 22:05:39 +01:00
parent ecac392dbe
commit 82f94c7861
10 changed files with 216 additions and 220 deletions

View File

@@ -66,9 +66,9 @@ func New(opts ...options.Option) (store.Store, error) {
}, nil
}
// In the cloudflare workers KV implemention, Sync() doesn't guarantee
// In the cloudflare workers KV implemention, List() doesn't guarantee
// anything as the workers API is eventually consistent.
func (w *workersKV) Sync() ([]*store.Record, error) {
func (w *workersKV) List() ([]*store.Record, error) {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()

View File

@@ -31,11 +31,11 @@ func TestCloudflare(t *testing.T) {
t.Fatal(err.Error())
}
records, err := wkv.Sync()
records, err := wkv.List()
if err != nil {
t.Fatalf("Sync: %s\n", err.Error())
t.Fatalf("List: %s\n", err.Error())
} else {
t.Log("Synced " + strconv.Itoa(len(records)) + " records")
t.Log("Listed " + strconv.Itoa(len(records)) + " records")
}
err = wkv.Write(