storage

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STORAGE_UNDEFINED_TYPE = iota
	STORAGE_FILESYSTEM
	STORAGE_MINIO
)

Variables

View Source
var ErrNotImplementedYet = fmt.Errorf("not implemented yet")

Functions

This section is empty.

Types

type ArchiveSegmentInfo added in v0.8.0

type ArchiveSegmentInfo struct {
	SegmentName string
	StartTime   time.Time
	FilePath    string
	Size        int64
}

ArchiveSegmentInfo contains metadata about an archive segment

type ArchiveStorage

type ArchiveStorage interface {
	Type() StorageType
	MakeBucket(string) error
	UploadFile(context.Context, ArchiveUnit) (string, error)
	// ListFiles returns segments in the given time range for a stream
	ListFiles(ctx context.Context, directory string, streamPrefix string, startTime, endTime time.Time) ([]ArchiveSegmentInfo, error)
	// GetFilePath returns the full path to serve a segment
	GetFilePath(ctx context.Context, directory, segmentName string) (string, error)
}

func NewFileSystemProvider

func NewFileSystemProvider(path string) (ArchiveStorage, error)

func NewMinioProvider

func NewMinioProvider(client *minio.Client, bucket, path string) (ArchiveStorage, error)

type ArchiveUnit

type ArchiveUnit struct {
	Bucket      string
	SegmentName string
	FileName    string
}

type FileSystemProvider

type FileSystemProvider struct {
	Path string
}

func (*FileSystemProvider) GetFilePath added in v0.8.0

func (storage *FileSystemProvider) GetFilePath(ctx context.Context, directory, segmentName string) (string, error)

GetFilePath returns the full path to a segment file

func (*FileSystemProvider) ListFiles added in v0.8.0

func (storage *FileSystemProvider) ListFiles(ctx context.Context, directory string, streamPrefix string, startTime, endTime time.Time) ([]ArchiveSegmentInfo, error)

ListFiles lists archive segments in the directory matching the stream prefix and time range Segment filenames are expected in format: {streamID}_{unixTimestamp}.mp4 It finds the segment containing startTime (largest timestamp <= startTime) and includes all segments from there up to endTime.

func (*FileSystemProvider) MakeBucket

func (storage *FileSystemProvider) MakeBucket(bucket string) error

func (*FileSystemProvider) Type

func (storage *FileSystemProvider) Type() StorageType

func (*FileSystemProvider) UploadFile

func (storage *FileSystemProvider) UploadFile(ctx context.Context, object ArchiveUnit) (string, error)

type MinioProvider

type MinioProvider struct {
	DefaultBucket string
	Path          string
	// contains filtered or unexported fields
}

func (*MinioProvider) GetFilePath added in v0.8.0

func (m *MinioProvider) GetFilePath(ctx context.Context, bucket, segmentName string) (string, error)

GetFilePath returns a presigned URL for the segment (valid for 1 hour)

func (*MinioProvider) ListFiles added in v0.8.0

func (m *MinioProvider) ListFiles(ctx context.Context, bucket string, streamPrefix string, startTime, endTime time.Time) ([]ArchiveSegmentInfo, error)

ListFiles lists archive segments in MinIO matching the stream prefix and time range

func (*MinioProvider) MakeBucket

func (m *MinioProvider) MakeBucket(bucket string) error

func (*MinioProvider) Type

func (m *MinioProvider) Type() StorageType

func (*MinioProvider) UploadFile

func (m *MinioProvider) UploadFile(ctx context.Context, object ArchiveUnit) (string, error)

UploadFile loads file to MinIO. Do not provide FileName field in ArchiveUnit object if you want to use Payload bytes; otherwise file will be loaded from filesystem by FileName field

type StorageType

type StorageType uint16

func NewStorageTypeFrom

func NewStorageTypeFrom(str string) StorageType

func (StorageType) String

func (iotaIdx StorageType) String() string

String returns string representation of the storage type

Jump to

Keyboard shortcuts

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