encode

package
v0.0.0-...-c70285d Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Debug bool = false

Debug flag

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	// IsEncodingAvailable will check if an encoding is avaialble in the db
	IsEncodingAvailable(ctx context.Context, encodingHash string) (bool, error)

	// GetEncoding gets encoding from the db
	GetEncoding(ctx context.Context, encodingHash string) ([]byte, error)

	//InsertEncoding will insert the encoding in the db
	InsertEncoding(ctx context.Context, encodingHash string, byteStream []byte) error

	//InsertEncodings will insert a list of encodings in the db
	InsertEncodings(ctx context.Context, encodings []string, blocks [][]byte) error

	//GetMultipleEncodings will get a list of encodings corresponding to the list provided
	GetMultipleEncodings(ctx context.Context, encodingHashList ...string) ([][]byte, error)
}

DB is an interface to the data structure which holds the encoding

type RedisDB

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

RedisDB provides the service to retreive and manage the encodings from the db

func NewRedisDB

func NewRedisDB() RedisDB

NewRedisDB will generate a new DB object satisfying the ENcodeDB ifc

func (*RedisDB) GetEncoding

func (r *RedisDB) GetEncoding(ctx context.Context, encodingHash string) ([]byte, error)

GetEncoding will get the encoding from the db

func (*RedisDB) GetMultipleEncodings

func (r *RedisDB) GetMultipleEncodings(ctx context.Context, encodingHashList ...string) ([][]byte, error)

GetMultipleEncodings will get the list of encodings from the db

func (*RedisDB) InsertEncoding

func (r *RedisDB) InsertEncoding(ctx context.Context, encodingHash string, byteStream []byte) error

InsertEncoding will insert the encoding in the db

func (*RedisDB) InsertEncodings

func (r *RedisDB) InsertEncodings(ctx context.Context, keys []string, blocks [][]byte) error

InsertEncodings will insert a collection of encodings in the db

func (*RedisDB) IsEncodingAvailable

func (r *RedisDB) IsEncodingAvailable(ctx context.Context, encodingHash string) (bool, error)

IsEncodingAvailable will check if encoding is present inside the db

type Service

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

Service class embodices the functionality to

func NewService

func NewService(database DB) Service

NewService creates a new struct for Service

func (*Service) AssembleBlob

func (s *Service) AssembleBlob(ctx context.Context, r encode.Recipe, b encode.BlockResponse, dbBlocks [][]byte, lengthOfByteStream int) ([]byte, error)

AssembleBlob will assemble the blob using the recipe and the byte streams

func (*Service) GetAvailableBlocksFromDB

func (s *Service) GetAvailableBlocksFromDB(ctx context.Context, recipe encode.Recipe) (encode.Declaration, [][]byte, error)

GetAvailableBlocksFromDB gets available blocks from db and constructs a declaration

func (*Service) GetDeclaration

func (s *Service) GetDeclaration(ctx context.Context, recipe encode.Recipe) (encode.Declaration, error)

GetDeclaration will get the 'declaration' which indicates which encodings reffered by the recipe are already held by the service for the recipe

func (*Service) InsertMissingEncodings

func (s *Service) InsertMissingEncodings(ctx context.Context, recipe encode.Recipe, d encode.Declaration, byteStream []byte) error

InsertMissingEncodings will insert the encoding in the backend data store

Jump to

Keyboard shortcuts

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