parameters

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NullType = iota
	ParametersType
	ParameterSetType
)
View Source
const BUFFER_SIZE = 63
View Source
const CHUNK_HEADER_SIZE = 8 + CHUNK_ID_LENGTH
View Source
const CHUNK_ID_LENGTH = kodex.RANDOM_ID_LENGTH
View Source
const CHUNK_VERSION = 1
View Source
const ENTRY_VERSION = 1

Variables

View Source
var FileParameterStoreForm = forms.Form{
	Fields: []forms.Field{
		forms.Field{
			Name: "filename",
			Validators: []forms.Validator{
				forms.IsRequired{},
				forms.IsString{},
				IsFilename{},
			},
		},
		forms.Field{
			Name: "format",
			Validators: []forms.Validator{
				forms.IsOptional{Default: "json"},
				forms.IsIn{Choices: []interface{}{"json"}},
			},
		},
		forms.Field{
			Name: "in-memory-config",
			Validators: []forms.Validator{
				forms.IsOptional{
					Default: map[string]interface{}{},
				},
				forms.IsStringMap{},
			},
		},
	},
}

Functions

func MakeFileParameterStore

func MakeFileParameterStore(config map[string]interface{}, definitions *kodex.Definitions) (kodex.ParameterStore, error)

func MakeInMemoryParameterStore

func MakeInMemoryParameterStore(config map[string]interface{}, definitions *kodex.Definitions) (kodex.ParameterStore, error)

Types

type ByPosition

type ByPosition struct {
	Entries   []*DataEntry
	Positions map[string]int
}

func (ByPosition) Len

func (b ByPosition) Len() int

func (ByPosition) Less

func (b ByPosition) Less(i, j int) bool

func (ByPosition) Swap

func (b ByPosition) Swap(i, j int)

type DataChunk

type DataChunk struct {
	// The number of chunks for this hash
	Chunks uint16
	// The index of this chunk
	Index uint16
	// The actual ID of the entry this chunk belongs to
	ID []byte
	// The actual data in this chunk
	Data []byte
}

func MakeDataChunk

func MakeDataChunk(id []byte, chunks, index uint16, data []byte) *DataChunk

func (*DataChunk) Read

func (d *DataChunk) Read(reader io.Reader) error

func (*DataChunk) Write

func (d *DataChunk) Write(writer io.Writer) error

Writes a data chunkn to the given writer

type DataEntry

type DataEntry struct {
	Type uint8
	ID   []byte
	Data []byte
}

func (*DataEntry) FromBytes

func (e *DataEntry) FromBytes(data []byte) error

func (*DataEntry) Reassemble

func (e *DataEntry) Reassemble(chunks []*DataChunk) error

func (*DataEntry) Split

func (e *DataEntry) Split() ([]*DataChunk, error)

Splits a data entry into multiple data chunks.

func (*DataEntry) ToBytes

func (e *DataEntry) ToBytes() []byte

type DataStore

type DataStore interface {
	// Write data to the store
	Write(*DataEntry) error
	// Read data from the store
	Read() ([]*DataEntry, error)
	Init() error
}

type FileDataStore

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

A file-based data store

func MakeFileDataStore

func MakeFileDataStore(filename, format string) *FileDataStore

func (*FileDataStore) Init

func (f *FileDataStore) Init() error

func (*FileDataStore) Read

func (f *FileDataStore) Read() ([]*DataEntry, error)

func (*FileDataStore) Write

func (f *FileDataStore) Write(entry *DataEntry) error

type FileParameterStore

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

The file parameter store uses an append-only file that it writes parameters to. This enables parallel writin to the store without locking. To ensure consistency of the written parameters, we implement a reconciliation method in our store.

Each

func (*FileParameterStore) AllParameterSets

func (p *FileParameterStore) AllParameterSets() ([]*kodex.ParameterSet, error)

func (*FileParameterStore) AllParameters

func (p *FileParameterStore) AllParameters() ([]*kodex.Parameters, error)

func (*FileParameterStore) Definitions

func (p *FileParameterStore) Definitions() *kodex.Definitions

func (*FileParameterStore) ParameterSet

func (p *FileParameterStore) ParameterSet(hash []byte) (*kodex.ParameterSet, error)

func (*FileParameterStore) Parameters

func (p *FileParameterStore) Parameters(action kodex.Action, parameterGroup *kodex.ParameterGroup) (*kodex.Parameters, error)

func (*FileParameterStore) ParametersById

func (p *FileParameterStore) ParametersById(id []byte) (*kodex.Parameters, error)

func (*FileParameterStore) SaveParameterSet

func (p *FileParameterStore) SaveParameterSet(parameterSet *kodex.ParameterSet) (bool, error)

func (*FileParameterStore) SaveParameters

func (p *FileParameterStore) SaveParameters(parameters *kodex.Parameters) (bool, error)

type InMemoryParameterStore

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

func (*InMemoryParameterStore) AllParameterSets

func (p *InMemoryParameterStore) AllParameterSets() ([]*kodex.ParameterSet, error)

func (*InMemoryParameterStore) AllParameters

func (p *InMemoryParameterStore) AllParameters() ([]*kodex.Parameters, error)

func (*InMemoryParameterStore) Definitions

func (p *InMemoryParameterStore) Definitions() *kodex.Definitions

func (*InMemoryParameterStore) DeleteParameterSet

func (p *InMemoryParameterStore) DeleteParameterSet(parameterSet *kodex.ParameterSet) error

func (*InMemoryParameterStore) DeleteParameters

func (p *InMemoryParameterStore) DeleteParameters(parameters *kodex.Parameters) error

func (*InMemoryParameterStore) ParameterSet

func (p *InMemoryParameterStore) ParameterSet(hash []byte) (*kodex.ParameterSet, error)

func (*InMemoryParameterStore) Parameters

func (p *InMemoryParameterStore) Parameters(action kodex.Action, parameterGroup *kodex.ParameterGroup) (*kodex.Parameters, error)

func (*InMemoryParameterStore) ParametersById

func (p *InMemoryParameterStore) ParametersById(id []byte) (*kodex.Parameters, error)

func (*InMemoryParameterStore) RestoreParameterSet

func (p *InMemoryParameterStore) RestoreParameterSet(data map[string]interface{}) (*kodex.ParameterSet, error)

func (*InMemoryParameterStore) RestoreParameters

func (p *InMemoryParameterStore) RestoreParameters(data map[string]interface{}) (*kodex.Parameters, error)

func (*InMemoryParameterStore) SaveParameterSet

func (p *InMemoryParameterStore) SaveParameterSet(parameterSet *kodex.ParameterSet) (bool, error)

func (*InMemoryParameterStore) SaveParameters

func (p *InMemoryParameterStore) SaveParameters(parameters *kodex.Parameters) (bool, error)

type IsFilename

type IsFilename struct{}

func (IsFilename) Validate

func (f IsFilename) Validate(value interface{}, values map[string]interface{}) (interface{}, error)

Jump to

Keyboard shortcuts

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