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 ¶
- func ServeAccessor(in io.Reader, out io.Writer, fs FS) error
- type DirEntry
- type FS
- type FileInfo
- type RemoteAccessor
- func (r *RemoteAccessor) Close() error
- func (r *RemoteAccessor) MkdirAll(rel string) error
- func (r *RemoteAccessor) ReadDir(rel string) ([]os.DirEntry, error)
- func (r *RemoteAccessor) ReadFile(rel string) ([]byte, error)
- func (r *RemoteAccessor) Remove(rel string) error
- func (r *RemoteAccessor) RemoveAll(rel string) error
- func (r *RemoteAccessor) Rename(oldRel, newRel string) error
- func (r *RemoteAccessor) Root() string
- func (r *RemoteAccessor) Stat(rel string) (os.FileInfo, error)
- func (r *RemoteAccessor) WriteFile(rel string, data []byte) error
- type Request
- type Response
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
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) 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
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 ¶
NewSession starts a worker session. closeF is invoked on Close (typically waits on the worker process).