storageworker

package
v1.0.40 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package storageworker implements the line-oriented JSON protocol spoken by cmd/carbon-storage in accessor mode and consumed by remote nodestorage adapters (OSS-281).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeAccessor

func ServeAccessor(in io.Reader, out io.Writer, fs FS) error

ServeAccessor runs the accessor worker loop on in and writes responses to out.

Types

type DirEntry

type DirEntry struct {
	Name  string `json:"name"`
	IsDir bool   `json:"is_dir"`
}

DirEntry is a directory listing entry returned by readdir.

type FS

type FS interface {
	Stat(rel string) (os.FileInfo, error)
	ReadFile(rel string) ([]byte, error)
	WriteFile(rel string, data []byte) error
	ReadDir(rel string) ([]os.DirEntry, error)
	MkdirAll(rel string) error
	Remove(rel string) error
	RemoveAll(rel string) error
	Rename(oldRel, newRel string) error
	Root() string
}

FS exposes the nodestorage.Accessor surface without importing nodestorage (the worker binary and remote client share this package).

type FileInfo

type FileInfo struct {
	Name    string `json:"name"`
	Size    int64  `json:"size"`
	IsDir   bool   `json:"is_dir"`
	ModTime int64  `json:"mod_time"`
	Mode    uint32 `json:"mode"`
}

FileInfo is the stat payload for a single path.

type RemoteAccessor

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

RemoteAccessor implements nodestorage.Accessor over a worker session.

func NewRemoteAccessor

func NewRemoteAccessor(s *Session) *RemoteAccessor

NewRemoteAccessor wraps a live worker session.

func (*RemoteAccessor) Close

func (r *RemoteAccessor) Close() error

func (*RemoteAccessor) MkdirAll

func (r *RemoteAccessor) MkdirAll(rel string) error

func (*RemoteAccessor) ReadDir

func (r *RemoteAccessor) ReadDir(rel string) ([]os.DirEntry, error)

func (*RemoteAccessor) ReadFile

func (r *RemoteAccessor) ReadFile(rel string) ([]byte, error)

func (*RemoteAccessor) Remove

func (r *RemoteAccessor) Remove(rel string) error

func (*RemoteAccessor) RemoveAll

func (r *RemoteAccessor) RemoveAll(rel string) error

func (*RemoteAccessor) Rename

func (r *RemoteAccessor) Rename(oldRel, newRel string) error

func (*RemoteAccessor) Root

func (r *RemoteAccessor) Root() string

func (*RemoteAccessor) Stat

func (r *RemoteAccessor) Stat(rel string) (os.FileInfo, error)

func (*RemoteAccessor) WriteFile

func (r *RemoteAccessor) WriteFile(rel string, data []byte) error

type Request

type Request struct {
	Op      string `json:"op"`
	Path    string `json:"path,omitempty"`
	Path2   string `json:"path2,omitempty"`
	Data    []byte `json:"data,omitempty"`
	Perms   uint32 `json:"perms,omitempty"`
	ModTime int64  `json:"mod_time,omitempty"`
}

Request is one JSON line sent to the worker.

type Response

type Response struct {
	OK       bool       `json:"ok"`
	Error    string     `json:"error,omitempty"`
	Data     []byte     `json:"data,omitempty"`
	Entries  []DirEntry `json:"entries,omitempty"`
	FileInfo *FileInfo  `json:"file_info,omitempty"`
	Root     string     `json:"root,omitempty"`
}

Response is one JSON line from the worker.

type Session

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

Session is a bidirectional JSONL channel to one accessor worker process.

func NewSession

func NewSession(in io.Writer, out io.Reader, closeF func() error) (*Session, error)

NewSession starts a worker session. closeF is invoked on Close (typically waits on the worker process).

func NewSessionContext

func NewSessionContext(ctx context.Context, in io.Writer, out io.Reader, closeF func() error) (*Session, error)

NewSessionContext binds worker startup and lifetime to the operation context. closeF must close the underlying input and output so blocked I/O can return.

func (*Session) Close

func (s *Session) Close() error

Close ends the worker session.

func (*Session) Root

func (s *Session) Root() string

Root returns the worker's confined data root.

Jump to

Keyboard shortcuts

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