Documentation
¶
Index ¶
- Constants
- Variables
- func WithinPrefixBoundary(path, prefix string) bool
- type CacheEntry
- type CacheGeneration
- type CacheStats
- type DeletePlan
- type Engine
- func (e *Engine) AddPeerEndpoint(instanceID, endpoint string) error
- func (e *Engine) Close()
- func (e *Engine) CountDirectoryChildren(ctx context.Context, path string) (int, error)
- func (e *Engine) CreateDirectory(ctx context.Context, path string, md *metadata.Metadata) error
- func (e *Engine) CreateErasureFile(ctx context.Context, path string, r io.Reader, opts *erasure.StoreOptions, ...) (*metadata.Metadata, error)
- func (e *Engine) DeleteDirectoryRecursive(ctx context.Context, path string) (int, int, error)
- func (e *Engine) DeleteFile(ctx context.Context, path string) error
- func (e *Engine) DeleteFileOnInstance(ctx context.Context, instanceID, path string) error
- func (e *Engine) DeleteMetadataOnly(ctx context.Context, path string) error
- func (e *Engine) DeletePrefixWithin(ctx context.Context, prefix string, boundary bool) (int, error)
- func (e *Engine) DeleteTreeOnInstance(ctx context.Context, instanceID, path string) error
- func (e *Engine) EnsureRootDirectory(ctx context.Context) error
- func (e *Engine) GetCurrentInstanceID() string
- func (e *Engine) GetErasureManager() *erasure.Manager
- func (e *Engine) GetFile(ctx context.Context, path string) (io.ReadCloser, error)
- func (e *Engine) GetMetadata(ctx context.Context, path string) (*metadata.Metadata, error)
- func (e *Engine) GetMetadataUncached(ctx context.Context, path string) (*metadata.Metadata, error)
- func (e *Engine) GetMetadataWithSource(ctx context.Context, path string) (*metadata.Metadata, bool, error)
- func (e *Engine) GetPeerEndpoint(instanceID string) string
- func (e *Engine) ListDirectory(ctx context.Context, path string) ([]*metadata.Metadata, error)
- func (e *Engine) ListDirectoryRecursive(ctx context.Context, path string, maxDepth int) ([]*metadata.Metadata, error)
- func (e *Engine) ListDirectoryRecursiveLimited(ctx context.Context, path string, maxDepth, limit int) ([]*metadata.Metadata, error)
- func (e *Engine) ListObjects(ctx context.Context, prefix, startAfter string, limit int) ([]*metadata.Metadata, bool, error)
- func (e *Engine) MetadataCache() *MetadataCache
- func (e *Engine) Move(ctx context.Context, srcPath, dstPath string, opts MoveOptions) error
- func (e *Engine) OpenFile(ctx context.Context, md *metadata.Metadata, path string) (io.ReadCloser, error)
- func (e *Engine) OpenFileRange(ctx context.Context, md *metadata.Metadata, path string, offset, length int64) (io.ReadCloser, error)
- func (e *Engine) PlanDelete(ctx context.Context, path string) (DeletePlan, error)
- func (e *Engine) ProbeStorage(ctx context.Context, name string) (StorageProbe, error)
- func (e *Engine) PutFile(ctx context.Context, path string, reader io.Reader, size int64, ...) (*metadata.Metadata, bool, error)
- func (e *Engine) RecoverOverwrites(ctx context.Context) error
- func (e *Engine) RemovePeerEndpoint(instanceID string)
- func (e *Engine) Rename(ctx context.Context, srcPath, newName string) error
- func (e *Engine) ReplicatePath(ctx context.Context, path string) error
- func (e *Engine) SearchDirectoryRecursiveLimited(ctx context.Context, path string, maxDepth, limit int, ...) ([]*metadata.Metadata, int, error)
- func (e *Engine) SetErasureManager(em *erasure.Manager)
- func (e *Engine) SetMetadataCacheSize(size int)
- func (e *Engine) SetMetadataCacheTTL(ttl time.Duration)
- func (e *Engine) SetReplicationFailureRecorder(record func(path, message string))
- func (e *Engine) SetReplicationOutcomeRecorder(record func(outcome string))
- func (e *Engine) SetStrict(strict bool)
- func (e *Engine) SetTrueOverwrite(enabled bool, tmpSaveMaxSize int64)
- func (e *Engine) UpdateFileOnInstance(ctx context.Context, instanceID, path string, reader io.Reader, size int64, ...) (string, error)
- func (e *Engine) UpdateMetadataOnly(ctx context.Context, md *metadata.Metadata) error
- func (e *Engine) UseTaskQueue(queue cluster.Queue)
- func (e *Engine) WalkPrefix(ctx context.Context, prefix string, boundary bool, ...) error
- type ErrInvalidRename
- type ErrProxyFailed
- type ErrUnsupportedMove
- type MetadataCache
- func (c *MetadataCache) Clear() int
- func (c *MetadataCache) Close()
- func (c *MetadataCache) Generation(path string) CacheGeneration
- func (c *MetadataCache) Get(path string) (*metadata.Metadata, bool)
- func (c *MetadataCache) Invalidate(path string)
- func (c *MetadataCache) InvalidatePrefix(prefix string) int
- func (c *MetadataCache) IsAbsent(path string) bool
- func (c *MetadataCache) SetAbsent(path string)
- func (c *MetadataCache) SetBypass(bypass bool)
- func (c *MetadataCache) SetIfGeneration(path string, md *metadata.Metadata, gen CacheGeneration)
- func (c *MetadataCache) SetMaxSize(size int)
- func (c *MetadataCache) SetTTL(ttl time.Duration)
- func (c *MetadataCache) Stats() CacheStats
- type MoveOptions
- type PrefixDeleteError
- type StorageProbe
- type Trash
- func (t *Trash) Cleanup(ctx context.Context, retention time.Duration) (int, error)
- func (t *Trash) Delete(ctx context.Context, userID, id string) error
- func (t *Trash) Empty(ctx context.Context, userID, deletedBy string) (jobs.Job, error)
- func (t *Trash) IsAdmin(userID string) bool
- func (t *Trash) List(ctx context.Context, userID, deletedBy, cursor string, limit int) (TrashPage, error)
- func (t *Trash) Logger() *zap.Logger
- func (t *Trash) MoveToTrash(ctx context.Context, userID, filePath string) (TrashItem, error)
- func (t *Trash) Restore(ctx context.Context, userID, id, to, onConflict string) (string, error)
- type TrashItem
- type TrashPage
- type UploadEngine
- type UploadOffsetError
- type UploadPart
- type UploadRequest
- type UploadResult
- type UploadSession
- type UploadState
- type Uploads
- func (u *Uploads) Abort(userID, id string) error
- func (u *Uploads) Cleanup(now time.Time) (int, error)
- func (u *Uploads) Complete(ctx context.Context, userID, id string) (UploadResult, error)
- func (u *Uploads) Create(ctx context.Context, userID string, req UploadRequest) (UploadSession, error)
- func (u *Uploads) Logger() *zap.Logger
- func (u *Uploads) PutPart(userID, id string, part UploadPart, body io.Reader) (UploadSession, error)
- func (u *Uploads) Status(userID, id string) (UploadSession, error)
Constants ¶
Variables ¶
var ( ErrUnknownStorage = errors.New("unknown storage backend") )
var ( ErrTrashInvalid = errors.New("invalid trash request") ErrTrashConflict = errors.New("destination already exists") )
var ( ErrUploadNotFound = errors.New("upload not found") ErrUploadExpired = errors.New("upload expired") ErrUploadNotOpen = errors.New("upload is not open") ErrUploadIncomplete = errors.New("upload is incomplete") ErrUploadInvalid = errors.New("invalid upload request") ErrUploadRange = errors.New("invalid upload part range") ErrUploadTooLarge = errors.New("upload exceeds size limit") ErrUploadExists = errors.New("file already exists") ErrUploadPathIsDirectory = errors.New("path is a directory") )
var ErrDirectoryNotEmpty = errors.New("directory not empty")
var ErrNotAFile = errors.New("path is not a file")
var ErrReplicaCommitPending = errors.New("write committed on primary, replica commit pending")
var ErrReplicationDisabled = errors.New("replication is disabled")
var ErrVerifyMismatch = errors.New("stored file does not match the uploaded bytes")
Functions ¶
func WithinPrefixBoundary ¶
Types ¶
type CacheEntry ¶
func (*CacheEntry) IsExpired ¶
func (e *CacheEntry) IsExpired() bool
type CacheGeneration ¶
type CacheGeneration struct {
// contains filtered or unexported fields
}
type CacheStats ¶
type DeletePlan ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine represents the core CallFS engine that orchestrates operations
func NewEngine ¶
func NewEngine( metadataStore metadata.Store, localFSBackend backends.Storage, s3Backend backends.Storage, internalProxyBackend backends.Storage, internalProxyAdapter *internalproxy.InternalProxyAdapter, lockManager locks.Manager, currentInstanceID string, peerEndpoints map[string]string, replicationEnabled bool, replicaBackend string, requireReplicaAck bool, logger *zap.Logger, ) *Engine
NewEngine creates a new core engine instance
func (*Engine) AddPeerEndpoint ¶
func (*Engine) Close ¶
func (e *Engine) Close()
Close shuts down the engine and releases background resources.
func (*Engine) CountDirectoryChildren ¶
CountDirectoryChildren returns the number of direct children of a directory whose metadata the caller has already resolved.
func (*Engine) CreateDirectory ¶
CreateDirectory creates a new directory
func (*Engine) CreateErasureFile ¶
func (*Engine) DeleteDirectoryRecursive ¶
func (*Engine) DeleteFileOnInstance ¶
DeleteFileOnInstance deletes a file on a specific instance using the internal proxy
func (*Engine) DeleteMetadataOnly ¶
func (*Engine) DeletePrefixWithin ¶
func (*Engine) DeleteTreeOnInstance ¶
func (*Engine) EnsureRootDirectory ¶
func (*Engine) GetCurrentInstanceID ¶
GetCurrentInstanceID returns the current instance ID
func (*Engine) GetErasureManager ¶
GetErasureManager returns the erasure manager (may be nil)
func (*Engine) GetMetadata ¶
func (*Engine) GetMetadataUncached ¶
func (*Engine) GetMetadataWithSource ¶
func (*Engine) GetPeerEndpoint ¶
GetPeerEndpoint returns the endpoint URL for a given instance ID
func (*Engine) ListDirectory ¶
ListDirectory lists directory contents
func (*Engine) ListDirectoryRecursive ¶
func (e *Engine) ListDirectoryRecursive(ctx context.Context, path string, maxDepth int) ([]*metadata.Metadata, error)
ListDirectoryRecursive lists directory contents recursively
func (*Engine) ListDirectoryRecursiveLimited ¶
func (e *Engine) ListDirectoryRecursiveLimited(ctx context.Context, path string, maxDepth, limit int) ([]*metadata.Metadata, error)
ListDirectoryRecursiveLimited lists directory contents recursively, returning at most limit entries (0 means unlimited)
func (*Engine) ListObjects ¶
func (*Engine) MetadataCache ¶
func (e *Engine) MetadataCache() *MetadataCache
func (*Engine) Move ¶
Move relocates a file or directory to dstPath, optionally changing its backend and/or owning instance.
func (*Engine) OpenFileRange ¶
func (*Engine) PlanDelete ¶
func (*Engine) ProbeStorage ¶
func (*Engine) RemovePeerEndpoint ¶
func (*Engine) Rename ¶
Rename changes only the name of a file or directory, leaving it in the same folder, backend, and instance. newName must be a single path segment.
func (*Engine) ReplicatePath ¶
func (*Engine) SearchDirectoryRecursiveLimited ¶
func (*Engine) SetErasureManager ¶
SetErasureManager sets the erasure manager on the engine
func (*Engine) SetMetadataCacheSize ¶
func (*Engine) SetMetadataCacheTTL ¶
func (*Engine) SetReplicationFailureRecorder ¶
func (*Engine) SetReplicationOutcomeRecorder ¶
func (*Engine) SetTrueOverwrite ¶
func (*Engine) UpdateFileOnInstance ¶
func (e *Engine) UpdateFileOnInstance(ctx context.Context, instanceID, path string, reader io.Reader, size int64, ifMatch string, ifNoneMatch bool) (string, error)
UpdateFileOnInstance updates a file on a specific instance using the internal proxy
func (*Engine) UpdateMetadataOnly ¶
func (*Engine) UseTaskQueue ¶
type ErrInvalidRename ¶
type ErrInvalidRename struct {
// contains filtered or unexported fields
}
ErrInvalidRename indicates a malformed rename/move request (bad name, moving a path into its own subtree, etc.). Mapped to 400 by the handler.
func (*ErrInvalidRename) Error ¶
func (e *ErrInvalidRename) Error() string
type ErrProxyFailed ¶
type ErrProxyFailed struct {
// contains filtered or unexported fields
}
func (*ErrProxyFailed) Error ¶
func (e *ErrProxyFailed) Error() string
func (*ErrProxyFailed) Unwrap ¶
func (e *ErrProxyFailed) Unwrap() error
type ErrUnsupportedMove ¶
type ErrUnsupportedMove struct {
// contains filtered or unexported fields
}
ErrUnsupportedMove indicates a relocation the current release does not perform (e.g. erasure re-tiering or cross-backend/instance directory moves). Mapped to 400.
func (*ErrUnsupportedMove) Error ¶
func (e *ErrUnsupportedMove) Error() string
type MetadataCache ¶
type MetadataCache struct {
// contains filtered or unexported fields
}
func NewMetadataCache ¶
func NewMetadataCache(ttl time.Duration, maxSize int) *MetadataCache
func (*MetadataCache) Clear ¶
func (c *MetadataCache) Clear() int
func (*MetadataCache) Close ¶
func (c *MetadataCache) Close()
func (*MetadataCache) Generation ¶
func (c *MetadataCache) Generation(path string) CacheGeneration
func (*MetadataCache) Invalidate ¶
func (c *MetadataCache) Invalidate(path string)
func (*MetadataCache) InvalidatePrefix ¶
func (c *MetadataCache) InvalidatePrefix(prefix string) int
func (*MetadataCache) IsAbsent ¶
func (c *MetadataCache) IsAbsent(path string) bool
func (*MetadataCache) SetAbsent ¶
func (c *MetadataCache) SetAbsent(path string)
func (*MetadataCache) SetBypass ¶
func (c *MetadataCache) SetBypass(bypass bool)
func (*MetadataCache) SetIfGeneration ¶
func (c *MetadataCache) SetIfGeneration(path string, md *metadata.Metadata, gen CacheGeneration)
func (*MetadataCache) SetMaxSize ¶
func (c *MetadataCache) SetMaxSize(size int)
func (*MetadataCache) SetTTL ¶
func (c *MetadataCache) SetTTL(ttl time.Duration)
func (*MetadataCache) Stats ¶
func (c *MetadataCache) Stats() CacheStats
type MoveOptions ¶
type MoveOptions struct {
Backend string // target backend type ("localfs", "s3", "erasure"); "" keeps source's
Instance string // target instance ID; "" keeps source's
Overwrite bool // replace an existing destination instead of failing
CreateParents bool // create missing destination parent directories
// contains filtered or unexported fields
}
MoveOptions controls a move operation. Empty Backend/Instance mean "keep the source's"; a different value triggers a physical relocation of the bytes.
type PrefixDeleteError ¶
func (*PrefixDeleteError) Error ¶
func (e *PrefixDeleteError) Error() string
func (*PrefixDeleteError) Unwrap ¶
func (e *PrefixDeleteError) Unwrap() error
type StorageProbe ¶
type Trash ¶
type Trash struct {
// contains filtered or unexported fields
}
func (*Trash) MoveToTrash ¶
type UploadEngine ¶
type UploadEngine interface {
GetMetadata(ctx context.Context, path string) (*metadata.Metadata, error)
PutFile(ctx context.Context, path string, reader io.Reader, size int64, md *metadata.Metadata, ifMatch string, ifNoneMatch bool) (*metadata.Metadata, bool, error)
CreateErasureFile(ctx context.Context, path string, r io.Reader, opts *erasure.StoreOptions, build func(*erasure.ErasureFileInfo) *metadata.Metadata) (*metadata.Metadata, error)
}
type UploadOffsetError ¶
type UploadOffsetError struct {
Offset int64
}
func (*UploadOffsetError) Error ¶
func (e *UploadOffsetError) Error() string
type UploadPart ¶
type UploadRequest ¶
type UploadResult ¶
type UploadSession ¶
type UploadSession struct {
ID string `json:"id"`
UserID string `json:"user_id"`
Path string `json:"path"`
Size int64 `json:"size"`
Offset int64 `json:"offset"`
Overwrite bool `json:"overwrite"`
IfMatch string `json:"if_match"`
Mode string `json:"mode"`
Storage string `json:"storage"`
Erasure *erasure.StoreOptions `json:"erasure"`
State UploadState `json:"state"`
ExpiresAt time.Time `json:"expires_at"`
}
type UploadState ¶
type UploadState string
const ( UploadOpen UploadState = "open" UploadCompleting UploadState = "completing" UploadDone UploadState = "done" UploadFailed UploadState = "failed" UploadExpired UploadState = "expired" )
type Uploads ¶
type Uploads struct {
// contains filtered or unexported fields
}
func NewUploads ¶
func NewUploads(engine UploadEngine, authorizer auth.Authorizer, localRoot, defaultBackend string, logger *zap.Logger) (*Uploads, error)
func (*Uploads) Create ¶
func (u *Uploads) Create(ctx context.Context, userID string, req UploadRequest) (UploadSession, error)
func (*Uploads) PutPart ¶
func (u *Uploads) PutPart(userID, id string, part UploadPart, body io.Reader) (UploadSession, error)