govch

package module
v0.0.0-...-bfc5318 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2021 License: MIT Imports: 17 Imported by: 0

README

GOVCH

GOVCH is a library for controlling version of data using hash method. This method permit veracity and integrity of versionning data.

Installation

go get -u github.com/jakofys/govch

Requirement

  • Golang 1.16 or more

Use

Controller

The controller interface the versionning logic using a io.ReadWriter as storage. Use a io.ReadWriter help to load current stored data for continue with it.

vc := govch.NewController(bytes.NewBuffer(nil)) // io.ReadWriter

Now, you can init first versioning of data. The structure must implement vch:"referent" tag to specify to GOVCH which identifier to use as reference. type Object struct{ ID int vch:"referent" Payload string }

obj := &Object{ID: 1, Payload: "payload"}

// Release method return a version of data c,err := vc.Commit(obj)


When you release a subject, that return a `Commit` object that allow you to know if exists changes between current data and the released data.
Be carefully, the commit is a way to emit a complete information about two data, without merge it in a branch.

If you want to make a commit effective (merged), make:

```go
vc.Merge(c) // When merged

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commit

type Commit struct {
	ID CommitID
	// contains filtered or unexported fields
}

Commit is a change that permit to know changed

func (Commit) Applied

func (c Commit) Applied() bool

Applied as new release of history

func (Commit) Changed

func (c Commit) Changed() bool

Changed from release

type CommitID

type CommitID string

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller store based on saga transaction pattern

func NewController

func NewController() *Controller

NewController new controller to handle versionning dataa

func (*Controller) Commit

func (c *Controller) Commit(data interface{}) (*Release, error)

Release from referent id (tag `vch:reference"`), return empty Release if not exists

func (*Controller) Dump

func (c *Controller) Dump(w io.Writer) error

func (*Controller) Import

func (c *Controller) Import(r io.Reader) error

func (*Controller) Release

func (c *Controller) Release(relId string) (*Release, error)

Release from referent id (tag `vch:reference"`), return empty Release if not exists

type EncryptedFile

type EncryptedFile struct {
	// contains filtered or unexported fields
}

EncryptedFile implement io.Writer, io.Reader, io.Closer It allow you to write and store data into encrypted file use privateKey

func NewEcryptedFile

func NewEcryptedFile(filename, privateKey string) (*EncryptedFile, error)

NewEncryptedFile with filename

func (*EncryptedFile) Close

func (e *EncryptedFile) Close() error

Close write the content into a file

func (*EncryptedFile) Read

func (e *EncryptedFile) Read(b []byte) (int, error)

Read from the buffer to byte list

func (*EncryptedFile) Write

func (e *EncryptedFile) Write(b []byte) (int, error)

Write implement io.Writer

type InexistentIDReferentError

type InexistentIDReferentError struct {
	// contains filtered or unexported fields
}

When extracting and not found a referent tag name

func (InexistentIDReferentError) Error

type Meta

type Meta map[string]interface{}

Meta is structure to store context data

func (Meta) Set

func (m Meta) Set(key string, value interface{})

type NoMatchDataTypeError

type NoMatchDataTypeError struct {
	// contains filtered or unexported fields
}

NoMatchDataTypeError define when existing release not match given data type

func (NoMatchDataTypeError) Error

func (e NoMatchDataTypeError) Error() string

Error to implement error native type

type Release

type Release struct {
	Meta      Meta
	Signature Signature
	// contains filtered or unexported fields
}

Release is a data version committed

func (*Release) LastCommit

func (r *Release) LastCommit() (*Commit, error)

Release from referent id (tag `vch:reference"`), return empty Release if not exists

func (*Release) Merge

func (r *Release) Merge(commit *Commit) error

Merge a commit confirmed data upgrading version of release

type Signature

type Signature []byte

type UnexistingCommitError

type UnexistingCommitError struct {
	// contains filtered or unexported fields
}

UnexistingCommitError look for commit from commit id, but doesn't exists

func (UnexistingCommitError) Error

func (e UnexistingCommitError) Error() string

Error to implement error native type

type UnexistingReleaseError

type UnexistingReleaseError struct {
	// contains filtered or unexported fields
}

UnexistingCommitError look for commit from commit id, but doesn't exists

func (UnexistingReleaseError) Error

func (e UnexistingReleaseError) Error() string

Error to implement error native type

type WrongPrivateKeyDecryptionError

type WrongPrivateKeyDecryptionError struct {
	Filename string
}

WrongPrivateKeyDecryptionError when trying to decrypt with the wrong private key

func (WrongPrivateKeyDecryptionError) Error

Error to implement error native type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL