Documentation
¶
Overview ¶
Package git provides git-based versioning for key-value storage. It tracks all changes to keys in a local git repository with optional push to remote.
Index ¶
- type Author
- type CommitRequest
- type Config
- type HistoryEntry
- type KeyValue
- type Service
- type Store
- func (s *Store) Checkout(rev string) error
- func (s *Store) Commit(req CommitRequest) error
- func (s *Store) Delete(key string, author Author) error
- func (s *Store) GetRevision(key, rev string) ([]byte, string, error)
- func (s *Store) Head() (string, error)
- func (s *Store) History(key string, limit int) ([]HistoryEntry, error)
- func (s *Store) Pull() error
- func (s *Store) Push() error
- func (s *Store) ReadAll() (map[string]KeyValue, error)
- type Storer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Author ¶ added in v0.4.0
Author represents the author of a git commit.
func DefaultAuthor ¶ added in v0.4.0
func DefaultAuthor() Author
DefaultAuthor returns the default author for git commits.
type CommitRequest ¶ added in v0.7.3
CommitRequest holds parameters for a git commit operation.
type Config ¶
type Config struct {
Path string // local repository path
Branch string // branch name (default: master)
Remote string // remote name (optional, for push/pull)
SSHKey string // path to SSH private key (optional, for push)
}
Config holds git repository configuration
type HistoryEntry ¶ added in v0.12.0
type HistoryEntry struct {
Hash string `json:"hash"`
Timestamp time.Time `json:"timestamp"`
Author string `json:"author"`
Operation string `json:"operation"`
Format string `json:"format"`
Value []byte `json:"value"`
}
HistoryEntry represents a single revision of a key.
type Service ¶ added in v0.9.1
type Service struct {
// contains filtered or unexported fields
}
Service wraps Store and provides orchestrated git operations. handles commit + optional pull/push sequence.
func NewService ¶ added in v0.9.1
NewService creates a new git service. if pushSync is true, commits will be followed by pull and push.
func (*Service) Commit ¶ added in v0.9.1
func (s *Service) Commit(req CommitRequest) error
Commit commits a key-value change to git and optionally syncs with remote.
func (*Service) Delete ¶ added in v0.9.1
Delete removes a key from git and optionally syncs with remote.
func (*Service) GetRevision ¶ added in v0.12.0
GetRevision returns value and format at specific revision.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides git-backed versioning for key-value storage
func (*Store) Commit ¶
func (s *Store) Commit(req CommitRequest) error
Commit writes key-value to file and commits to git.
func (*Store) Delete ¶
Delete removes key file and commits the deletion. The author parameter specifies who made the change.
func (*Store) GetRevision ¶ added in v0.12.0
GetRevision returns value and format at specific revision.
func (*Store) History ¶ added in v0.12.0
func (s *Store) History(key string, limit int) ([]HistoryEntry, error)
History returns commit history for a key (newest first). limit specifies maximum number of entries to return (0 = unlimited).
func (*Store) ReadAll ¶
ReadAll reads all key-value pairs from the repository with their formats. Format is extracted from the commit message metadata of the last commit that modified each file. If no format is found in the commit message, defaults to "text".
Note: this function has O(n) git log queries where n is the number of files, as getFileFormat opens a git log iterator for each file. This is acceptable for restore operations which are infrequent admin commands.
type Storer ¶ added in v0.9.1
type Storer interface {
Commit(req CommitRequest) error
Delete(key string, author Author) error
Pull() error
Push() error
History(key string, limit int) ([]HistoryEntry, error)
GetRevision(key string, rev string) ([]byte, string, error)
}
Storer defines the interface for git store operations needed by Service.