-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new inmem and filekv storage backends (#68)
- Loading branch information
1 parent
42b2218
commit 15d2ac2
Showing
21 changed files
with
415 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Package diskv implements a NanoDEP storage backend using the diskv key-value store. | ||
package diskv | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/micromdm/nanodep/storage/kv" | ||
|
||
"github.com/micromdm/nanolib/storage/kv/kvdiskv" | ||
"github.com/micromdm/nanolib/storage/kv/kvtxn" | ||
"github.com/peterbourgon/diskv/v3" | ||
) | ||
|
||
// Diskv is a storage backend that uses diskv. | ||
type Diskv struct { | ||
*kv.KV | ||
} | ||
|
||
// New creates a new storage backend that uses diskv. | ||
func New(path string) *Diskv { | ||
return &Diskv{KV: kv.New( | ||
kvtxn.New(kvdiskv.New(diskv.New(diskv.Options{ | ||
BasePath: filepath.Join(path, "dep_names"), | ||
Transform: kvdiskv.FlatTransform, | ||
CacheSizeMax: 1024 * 1024, | ||
}))), | ||
)} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package diskv | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/micromdm/nanodep/storage/test" | ||
) | ||
|
||
func TestFileStorage(t *testing.T) { | ||
test.TestWithStorages(t, context.Background(), New(t.TempDir())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Package inmem implements an in-memory NanoDEP storage backend. | ||
package inmem | ||
|
||
import ( | ||
"github.com/micromdm/nanodep/storage/kv" | ||
|
||
"github.com/micromdm/nanolib/storage/kv/kvmap" | ||
"github.com/micromdm/nanolib/storage/kv/kvtxn" | ||
) | ||
|
||
// InMem is an in-memory storage backend. | ||
type InMem struct { | ||
*kv.KV | ||
} | ||
|
||
// New creates a new in-memory storage backend. | ||
func New() *InMem { | ||
return &InMem{KV: kv.New(kvtxn.New(kvmap.New()))} | ||
} |
Oops, something went wrong.