uploadcache

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package uploadcache 管理 HTTP 上传接收资格、暂存内容及任务持有期。

Index

Constants

View Source
const (
	RoutePrefix       = "/mcp/uploads/"
	MaxFileSize int64 = 1 << 30
	MaxMetadata       = 1 << 20
)

Variables

View Source
var (
	ErrTooLarge     = errors.New("上传内容超过限制")
	ErrCapacity     = errors.New("上传暂存额度不足")
	ErrBusy         = errors.New("HTTP 接收并发已满")
	ErrExpired      = errors.New("上传接收对象已过期或不存在")
	ErrInvalidToken = errors.New("上传接收凭据无效")
	ErrClosed       = errors.New("上传接收服务已停止")
	ErrSizeMismatch = errors.New("上传内容长度不符")
	ErrNotReady     = errors.New("上传内容尚未完整接收")
	ErrUsed         = errors.New("上传内容已固定或已提交任务")
	ErrChanged      = errors.New("上传暂存文件身份已变化")
)

Functions

This section is empty.

Types

type Lease

type Lease struct {
	File *os.File
	// contains filtered or unexported fields
}

func (*Lease) Close

func (l *Lease) Close() error

type Options

type Options struct {
	Directory                      string
	Now                            func() time.Time
	TTL, ScanInterval, LockTimeout time.Duration
	MaxFileSize, MaxBytes          int64
	MaxFiles, MaxTransfers         int
	OnCleanupError                 func(error)
}

type Receiver

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

func (*Receiver) Abort

func (r *Receiver) Abort() (result error)

func (*Receiver) Complete

func (r *Receiver) Complete() error

func (*Receiver) Done

func (r *Receiver) Done() <-chan struct{}

func (*Receiver) Size

func (r *Receiver) Size() int64

func (*Receiver) Write

func (r *Receiver) Write(data []byte) (int, error)

type Store

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

func New

func New(o Options) (*Store, error)

func (*Store) BeginReceive

func (s *Store) BeginReceive(id, signature string) (*Receiver, error)

func (*Store) Cancel

func (s *Store) Cancel(id string) (View, error)

func (*Store) Claim

func (s *Store) Claim(id, task string) (*Lease, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) Counts

func (s *Store) Counts() (sources, receiving int)

func (*Store) Done

func (s *Store) Done() <-chan struct{}

func (*Store) Get

func (s *Store) Get(id string) (View, error)

func (*Store) Reserve

func (s *Store) Reserve(size int64, metadata []byte) (View, error)

func (*Store) SetMetadata

func (s *Store) SetMetadata(id string, metadata []byte) error

SetMetadata 只在准备阶段写入一次目标和清单,不能改写已经提供接收地址的对象。

func (*Store) Signature

func (s *Store) Signature(id string) (string, error)

func (*Store) Sweep

func (s *Store) Sweep() error

type View

type View struct {
	ID             string     `json:"source_id"`
	Size           int64      `json:"size"`
	State          string     `json:"state"`
	ExpiresAt      time.Time  `json:"receive_expires_at"`
	ReadyExpiresAt *time.Time `json:"ready_expires_at,omitempty"`
	UploadID       string     `json:"upload_id,omitempty"`
	Metadata       []byte     `json:"-"`
}

Jump to

Keyboard shortcuts

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