transfer

package
v0.0.0-...-f0b9b21 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrUnallocatedStream is throw when an action is attempted to be performed on a
	// nil stream.
	ErrUnallocatedStream = Error("unallocated stream")

	// ErrInactive is thrown when a transfer is expected to be active, but it's inactive.
	ErrInactive = Error("inactive transfer")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error string

Error is a custom error implementation for the `transfer` package in-order to have them stored as constants.

func ErrHashVerification

func ErrHashVerification(expectedHash, outcomeHash string) Error

ErrHashVerification is thrown during the verification process, when the metadata hash does not match the stream hash

func ErrRequestAdler32Checksum

func ErrRequestAdler32Checksum(request *grpc_runner_v1.StreamRequest, outcome uint32) Error

ErrRequestAdler32Checksum is thrown during the stream upload process, when the request fnv32a does not match the []byte request content.

func ErrSizeVerification

func ErrSizeVerification(expectedSize, outcomeSize int64) Error

ErrSizeVerification is thrown during the verification process, when the metadata size does not match the stream size

func (Error) Error

func (e Error) Error() string

type Metadata

type Metadata struct {
	Video *MetadataVideo `json:"video"`
	Image *MetadataImage `json:"image"`
}

type MetadataImage

type MetadataImage struct {
	SHA256 string `json:"sha256"`
	Size   int64  `json:"size"`
}

type MetadataVideo

type MetadataVideo struct {
	Dimension *MetadataVideoDimension `json:"dimension"`
	SHA256    string                  `json:"sha256"`
	CRC32     string                  `json:"crc32"`
	Duration  float64                 `json:"duration"`
	Size      int64                   `json:"size"`
}

type MetadataVideoDimension

type MetadataVideoDimension struct {
	Height int64 `json:"height"`
	Width  int64 `json:"width"`
}

type Stream

type Stream interface {
	io.Reader
	io.Seeker
	io.WriterAt
	io.Closer
	Stat() (fs.FileInfo, error)
	Name() string
}

Stream consists of all the methods required for a transfer we're basically interfacing out the *os.File so other methods could make use of this method (say in the future we decide to store in an S3 bucket).

func NewNoopStream

func NewNoopStream() Stream

type StreamChunk

type StreamChunk struct {
	Start int64
	End   int64
}

type StreamChunks

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

func NewStreamChunks

func NewStreamChunks(chunks ...StreamChunk) *StreamChunks

func (*StreamChunks) Append

func (c *StreamChunks) Append(
	req *grpc_runner_v1.StreamRequest,
) (err error)

func (*StreamChunks) Chunks

func (c *StreamChunks) Chunks() (streamChunks []StreamChunk)

func (*StreamChunks) Copy

func (c *StreamChunks) Copy() (streamChunks *StreamChunks)

func (*StreamChunks) Len

func (c *StreamChunks) Len() int

func (*StreamChunks) Less

func (c *StreamChunks) Less(i, j int) bool

func (*StreamChunks) Merge

func (c *StreamChunks) Merge()

func (*StreamChunks) Missing

func (c *StreamChunks) Missing() (streamChunks []StreamChunk)

func (*StreamChunks) Reset

func (c *StreamChunks) Reset()

func (*StreamChunks) Swap

func (c *StreamChunks) Swap(i, j int)

type Transfer

type Transfer interface {
	Active() bool

	Setup(anime domain.AnimeBase, imageFs, videoFs Stream)

	WriterAt(typ grpc_runner_v1.StreamType) io.WriterAt
	Reader(typ grpc_runner_v1.StreamType) io.Reader
	Corrupt(request *grpc_runner_v1.StreamRequest)

	CorruptParts() int
	IsCurrent(anime domain.AnimeBase) bool

	SetMetadata(metadata Metadata)

	Metadata() Metadata
	Anime() domain.AnimeBase

	Verify() error
	Close() error
}

func New

func New() Transfer

Jump to

Keyboard shortcuts

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