meta

package
v0.0.0-...-97b9ebb Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package meta provides interfaces and implementations to work with metadata protocol of DeGitX, metadata structure is an abstract key-value storage.

Index

Constants

View Source
const StandardTimeout = 30 * time.Second

StandardTimeout of blocking operations

Variables

This section is empty.

Functions

func SetSync

func SetSync(meta Storage, key string, value Data) error

SetSync updates metadata storage with new value for key and blocks execution with standard timeout.

Types

type Data

type Data string

Data - alias for immutable bytes representation with helper methods

func GetSync

func GetSync(meta Storage, key string) (Data, error)

GetSync fetches metadata value from remote storage and blocks execution with standard timeout to return metadata values

func (Data) Slice

func (md Data) Slice() []byte

Slice returns metadata slice of immutable byte array

type ErrNotFound

type ErrNotFound struct {
	Key string
}

ErrNotFound returned if a value for key was not found

func (*ErrNotFound) Error

func (e *ErrNotFound) Error() string

type Response

type Response struct {
	// Key of metadata response
	Key string
	// Value of metadata
	Value Data
	// Error on failure
	Error error
}

Response - type of metadata storage response

type Storage

type Storage interface {
	// Get returns a channel with single response item,
	// channel is closed on context cancellation. Context
	// shold be cancelled with defer.
	Get(ctx context.Context, key string) <-chan *Response
	// Set updates metadata storage, channel with a
	// value is returned on success, a value could differ from
	// provided value, if storage received new value after this request
	// but before response. Channel is closed on context
	// cancellation. Context should be cancelled with defer.
	Set(ctx context.Context, key string, val Data) <-chan *Response
}

Storage - interface of metadata storage with async operations

func NewInMemStorage

func NewInMemStorage() Storage

NewInMemStorage creates metadata storage in memory, useful for testing

Jump to

Keyboard shortcuts

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