front

package
v0.0.0-...-c286f04 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package front implements frontend service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(
	baseCtx context.Context,
	clientConstructor NodeClientConstructor,
	storage HandlerStorage,
	tracerProvider trace.TracerProvider,
	meterProvider metric.MeterProvider,
) (http.Handler, error)

Types

type Chunk

type Chunk struct {
	Index       int
	ID          uuid.UUID
	Offset      int64
	Size        int64
	NodeBaseURL string // [Node.BaseURL]
}

type ChunksNotFound

type ChunksNotFound struct {
	File string
}

func (*ChunksNotFound) Error

func (e *ChunksNotFound) Error() string

type DefaultNodeClientConstructor

type DefaultNodeClientConstructor struct {
	HTTPClient     node.HTTPClient
	TracerProvider trace.TracerProvider
}

func NewDefaultNodeClientConstructor

func NewDefaultNodeClientConstructor(httpClient node.HTTPClient, tracerProvider trace.TracerProvider) *DefaultNodeClientConstructor

func (*DefaultNodeClientConstructor) NewClient

func (c *DefaultNodeClientConstructor) NewClient(baseURL string) NodeClient

type File

type File struct {
	Size   int64
	Name   string
	Chunks []Chunk
}

type FileNotFoundErr

type FileNotFoundErr struct {
	File string
}

func (*FileNotFoundErr) Error

func (e *FileNotFoundErr) Error() string

type Handler

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

func (*Handler) GetClient

func (h *Handler) GetClient(baseURL string) NodeClient

GetClient creates or returns existing client to baseURL.

func (*Handler) NextClients

func (h *Handler) NextClients(ctx context.Context, n int) ([]NodeClient, error)

NextClients returns next N clients with least amount of data.

type HandlerStorage

type HandlerStorage interface {
	File(ctx context.Context, name string) (*File, error)
	AddFile(ctx context.Context, file File) error
	RemoveFile(ctx context.Context, name string) error
	Nodes(ctx context.Context) ([]Node, error)
	NodeStats(ctx context.Context) ([]NodeStat, error)
	AddNode(ctx context.Context, node Node) error
}

type LimitReaderFrom

type LimitReaderFrom struct {
	R      io.ReaderAt
	N      int64
	Offset int64
}

LimitReaderFrom is a reader that reads from R at Offset but stops with EOF after N bytes.

func (*LimitReaderFrom) Read

func (l *LimitReaderFrom) Read(p []byte) (n int, err error)

type Node

type Node struct {
	BaseURL string
}

type NodeClient

type NodeClient interface {
	Read(ctx context.Context, chunkID uuid.UUID, w io.Writer) error
	Write(ctx context.Context, chunkID uuid.UUID, r io.Reader) error
	Delete(ctx context.Context, id uuid.UUID) error
	BaseURL() string
}

type NodeClientConstructor

type NodeClientConstructor interface {
	NewClient(baseURL string) NodeClient
}

type NodeStat

type NodeStat struct {
	BaseURL     string
	TotalChunks int
	TotalSize   int64
}

type YDBStorage

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

func NewYDBStorage

func NewYDBStorage(db *ydb.Driver, tracer trace.Tracer) *YDBStorage

func (YDBStorage) AddFile

func (y YDBStorage) AddFile(ctx context.Context, file File) error

func (YDBStorage) AddNode

func (y YDBStorage) AddNode(ctx context.Context, node Node) error

func (YDBStorage) CreateTables

func (y YDBStorage) CreateTables(ctx context.Context) error

func (YDBStorage) File

func (y YDBStorage) File(ctx context.Context, name string) (*File, error)

func (YDBStorage) NodeStats

func (y YDBStorage) NodeStats(ctx context.Context) ([]NodeStat, error)

func (YDBStorage) Nodes

func (y YDBStorage) Nodes(ctx context.Context) ([]Node, error)

func (YDBStorage) RemoveFile

func (y YDBStorage) RemoveFile(ctx context.Context, name string) error

Jump to

Keyboard shortcuts

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