Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yunginnanet committed Jun 22, 2024
1 parent 0ee8b60 commit e33f973
Show file tree
Hide file tree
Showing 7 changed files with 706 additions and 45 deletions.
191 changes: 175 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@

`import "git.tcp.direct/tcp.direct/database"`

## Documentation

#### func AllKeepers

```go
func AllKeepers() map[string]KeeperCreator
```
> [!WARNING]
> This package is pre-v1 and the API is NOT stable!
#### func RegisterKeeper
## Documentation

```go
func RegisterKeeper(name string, keeper KeeperCreator)
var ErrKeyNotFound = errors.New("key not found")
```

#### type Filer
Expand Down Expand Up @@ -60,18 +55,28 @@ store to satisfy an overencompassing interface.
type Keeper interface {
// Path should return the base path where all stores should be stored under. (likely as subdirectories)
Path() string

// Init should initialize our Filer at the given path, to be referenced and called by dataStore.
Init(name string, options ...any) error
// With provides access to the given dataStore by providing a pointer to the related Filer.
With(name string) Store

// WithNew should initialize a new Filer at the given path.
With(name string) Filer
// WithNew should initialize a new Filer at the given path and return a pointer to it.
WithNew(name string, options ...any) Filer

// Destroy should remove the Filer by the given name.
// It is up to the implementation to decide if the data should be removed or not.
Destroy(name string) error

Discover() ([]string, error)

AllStores() map[string]Filer

// BackupAll should create a backup of all [Filer] instances in the [Keeper].
BackupAll(archivePath string) (models.Backup, error)

// RestoreAll should restore all [Filer] instances from the given archive.
RestoreAll(archivePath string) error

Meta() models.Metadata

Close(name string) error
Expand All @@ -96,20 +101,174 @@ type KeeperCreator func(path string) (Keeper, error)
```


#### func GetKeeper
#### type MockFiler

```go
type MockFiler struct {
}
```


#### func (*MockFiler) Backend

```go
func (m *MockFiler) Backend() any
```

#### func (*MockFiler) Close

```go
func (m *MockFiler) Close() error
```

#### func (*MockFiler) Delete

```go
func (m *MockFiler) Delete(key []byte) error
```

#### func (*MockFiler) Get

```go
func (m *MockFiler) Get(key []byte) ([]byte, error)
```

#### func (*MockFiler) Has

```go
func (m *MockFiler) Has(key []byte) bool
```

#### func (*MockFiler) Keys

```go
func (m *MockFiler) Keys() [][]byte
```

#### func (*MockFiler) Len

```go
func (m *MockFiler) Len() int
```

#### func (*MockFiler) Put

```go
func (m *MockFiler) Put(key []byte, value []byte) error
```

#### func (*MockFiler) Sync

```go
func (m *MockFiler) Sync() error
```

#### type MockKeeper

```go
type MockKeeper struct {
}
```


#### func NewMockKeeper

```go
func NewMockKeeper(name string) *MockKeeper
```

#### func (*MockKeeper) AllStores

```go
func (m *MockKeeper) AllStores() map[string]Filer
```

#### func (*MockKeeper) BackupAll

```go
func (m *MockKeeper) BackupAll(archivePath string) (models.Backup, error)
```

#### func (*MockKeeper) Close

```go
func (m *MockKeeper) Close(name string) error
```

#### func (*MockKeeper) CloseAll

```go
func (m *MockKeeper) CloseAll() error
```

#### func (*MockKeeper) Destroy

```go
func (m *MockKeeper) Destroy(name string) error
```

#### func (*MockKeeper) Discover

```go
func (m *MockKeeper) Discover() ([]string, error)
```

#### func (*MockKeeper) Init

```go
func (m *MockKeeper) Init(name string, options ...any) error
```

#### func (*MockKeeper) Meta

```go
func (m *MockKeeper) Meta() models.Metadata
```

#### func (*MockKeeper) Path

```go
func (m *MockKeeper) Path() string
```

#### func (*MockKeeper) RestoreAll

```go
func (m *MockKeeper) RestoreAll(archivePath string) error
```

#### func (*MockKeeper) SyncAll

```go
func (m *MockKeeper) SyncAll() error
```

#### func (*MockKeeper) SyncAndCloseAll

```go
func (m *MockKeeper) SyncAndCloseAll() error
```

#### func (*MockKeeper) With

```go
func (m *MockKeeper) With(name string) Filer
```

#### func (*MockKeeper) WithNew

```go
func GetKeeper(name string) KeeperCreator
func (m *MockKeeper) WithNew(name string, options ...any) Filer
```

#### type Searcher

```go
type Searcher interface {
// PrefixScan must retrieve all keys in the datastore and stream them to the given channel.
PrefixScan(prefix string) (<-chan *kv.KeyValue, chan error)
PrefixScan(prefix string) (<-chan kv.KeyValue, chan error)
// Search must be able to search through the value contents of our database and stream the results to the given channel.
Search(query string) (<-chan *kv.KeyValue, chan error)
Search(query string) (<-chan kv.KeyValue, chan error)
// ValueExists searches for an exact match of the given value and returns the key that contains it.
ValueExists(value []byte) (key []byte, ok bool)
}
Expand Down
36 changes: 30 additions & 6 deletions backup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@



#### func RestoreTarGzBackup

```go
func RestoreTarGzBackup(inPath string, outPath string) error
```

#### func VerifyBackup

```go
func VerifyBackup(metadata BackupMetadata) error
```

#### type BackupMetadata

```go
Expand All @@ -16,12 +28,24 @@ type BackupMetadata struct {
```


#### func NewTarGzBackup

```go
func NewTarGzBackup(inPath string, outPath string, stores []string, extraData ...[]byte) (BackupMetadata, error)
```

#### func (BackupMetadata) Format

```go
func (bm BackupMetadata) Format() string
```

#### func (BackupMetadata) MarshalJSON

```go
func (bm BackupMetadata) MarshalJSON() ([]byte, error)
```

#### func (BackupMetadata) Path

```go
Expand All @@ -34,6 +58,12 @@ func (bm BackupMetadata) Path() string
func (bm BackupMetadata) Timestamp() time.Time
```

#### func (BackupMetadata) Type

```go
func (bm BackupMetadata) Type() string
```

#### type Checksum

```go
Expand Down Expand Up @@ -67,12 +97,6 @@ type TarGzBackup struct {
```


#### func NewTarGzBackup

```go
func NewTarGzBackup(inPath string, outPath string, stores []string, extraData ...[]byte) (*TarGzBackup, error)
```

#### func (*TarGzBackup) Format

```go
Expand Down
Loading

0 comments on commit e33f973

Please sign in to comment.