chunk

package
v0.0.0-...-ebb3a86 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxChunkTags             = 4
	MaxChunkNameChars        = 50
	MaxChunkDescriptionChars = 100
)

Variables

This section is empty.

Functions

func ChunkToTransport

func ChunkToTransport(domain Chunk) *chunkv1alpha1.Chunk

func FileHashSliceToTransport

func FileHashSliceToTransport(domain []FileHash) []*chunkv1alpha1.FileHashes

func FlavorToTransport

func FlavorToTransport(domain Flavor) *chunkv1alpha1.Flavor

func FlavorVersionToTransport

func FlavorVersionToTransport(domain FlavorVersion) *chunkv1alpha1.FlavorVersion

Types

type Chunk

type Chunk struct {
	ID          string
	Name        string
	Description string
	Tags        []string
	Flavors     []Flavor
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

type File

type File struct {
	Path string
	Data []byte
}

type FileHash

type FileHash struct {
	Path string
	Hash string
}

func FileHashSliceToDomain

func FileHashSliceToDomain(transport []*chunkv1alpha1.FileHashes) []FileHash

func (FileHash) CalculateHash

func (f FileHash) CalculateHash() ([]byte, error)

func (FileHash) Equals

func (f FileHash) Equals(other merkletree.Content) (bool, error)

type Flavor

type Flavor struct {
	ID        string
	Name      string
	CreatedAt time.Time
	UpdatedAt time.Time
}

func FlavorToDomain

func FlavorToDomain(transport *chunkv1alpha1.Flavor) Flavor

type FlavorVersion

type FlavorVersion struct {
	ID            string
	Flavor        Flavor
	Version       string
	Hash          string
	ChangeHash    string
	FileHashes    []FileHash
	FilesUploaded bool
	CreatedAt     time.Time
}

func FlavorVersionToDomain

func FlavorVersionToDomain(transport *chunkv1alpha1.FlavorVersion) FlavorVersion

type FlavorVersionDiff

type FlavorVersionDiff struct {
	Added   []FileHash
	Removed []FileHash
	Changed []FileHash
}

type Repository

type Repository interface {
	CreateChunk(ctx context.Context, chunk Chunk) (Chunk, error)
	GetChunkByID(ctx context.Context, id string) (Chunk, error)
	UpdateChunk(ctx context.Context, chunk Chunk) (Chunk, error)
	ListChunks(ctx context.Context) ([]Chunk, error)
	ChunkExists(ctx context.Context, id string) (bool, error)
	CreateFlavor(ctx context.Context, chunkID string, flavor Flavor) (Flavor, error)
	ListFlavorsByChunkID(ctx context.Context, chunkID string) ([]Flavor, error)
	FlavorNameExists(ctx context.Context, chunkID string, name string) (bool, error)
	FlavorVersionExists(ctx context.Context, flavorID string, version string) (bool, error)
	FlavorVersionByHash(ctx context.Context, hash string) (string, error)
	LatestFlavorVersion(ctx context.Context, flavorID string) (FlavorVersion, error)
	CreateFlavorVersion(ctx context.Context, version FlavorVersion, prevVersionID string) (FlavorVersion, error)
	FlavorVersionHashByID(ctx context.Context, id string) (string, error)
	MarkFlavorVersionFilesUploaded(ctx context.Context, flavorVersionID string) error
	FlavorVersionByID(ctx context.Context, id string) (FlavorVersion, error)
}

type Server

type Server struct {
	chunkv1alpha1.UnimplementedChunkServiceServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(service Service) *Server

func (*Server) GetChunk

type Service

type Service interface {
	CreateChunk(ctx context.Context, chunk Chunk) (Chunk, error)
	GetChunk(ctx context.Context, id string) (Chunk, error)
	UpdateChunk(ctx context.Context, new Chunk) (Chunk, error)
	ListChunks(ctx context.Context) ([]Chunk, error)
	CreateFlavor(ctx context.Context, chunkID string, flavor Flavor) (Flavor, error)
	ListFlavors(ctx context.Context, chunkID string) ([]Flavor, error)
	CreateFlavorVersion(ctx context.Context, version FlavorVersion) (FlavorVersion, FlavorVersionDiff, error)
	SaveFlavorFiles(ctx context.Context, versionID string, files []File) error
}

func NewService

func NewService(repo Repository, blobStore blob.Store) Service

Jump to

Keyboard shortcuts

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