Documentation
¶
Index ¶
- Constants
- func DecompressInto(w io.Writer, b []byte) (int64, error)
- type BlobIndexChunk
- type Cache
- type Caibx
- type ChunkID
- type ChunkMissing
- type Header
- type Index
- type LocalStore
- type Message
- type RemoteSSH
- type Session
- func (s Session) ReadMessage() (Message, error)
- func (s Session) RecvHello() (uint64, error)
- func (s Session) RequestChunk(id ChunkID) ([]byte, error)
- func (s Session) SendHello(flags uint64) error
- func (s Session) SendProtocolRequest(id ChunkID, flags uint64) error
- func (s Session) WriteMessage(m Message) error
- type Store
Constants ¶
const ( // Format identifiers CaFormatIndex = 0x96824D9C7B129FF9 CaFormatHeader = 0xE75B9E112F17417D // Protocol message types CaProtocolHello = 0x3c71d0948ca5fbee CaProtocolIndex = 0xb32a91dd2b3e27f8 CaProtocolIndexEOF = 0x4f0932f1043718f5 CaProtocolArchive = 0x95d6428a69eddcc5 CaProtocolArchiveEOF = 0x450bef663f24cbad CaProtocolRequest = 0x8ab427e0f89d9210 CaProtocolChunk = 0x5213dd180a84bc8c CaProtocolMissing = 0xd010f9fac82b7b6c CaProtocolGoodbye = 0xad205dbf1a3686c3 CaProtocolAbort = 0xe7d9136b7efea352 // Provided services CaProtocolReadableStore = 0x1 CaProtocolWritableStore = 0x2 CaProtocolReadableIndex = 0x4 CaProtocolWritableIndex = 0x8 CaProtocolReadableArchive = 0x10 CaProtocolWritableArchive = 0x20 // Wanted services CaProtocolPullChunks = 0x40 CaProtocolPullIndex = 0x80 CaProtocolPullArchive = 0x100 CaProtocolPushChunks = 0x200 CaProtocolPushIndex = 0x400 CaProtocolPushIndexChunks = 0x800 CaProtocolPushArchive = 0x1000 // Protocol request flags CaProtocolRequestHighPriority = 1 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BlobIndexChunk ¶
BlobIndexChunk is a table entry in a caibx file containing the chunk ID (SHA256) as well as the offset within the blob after appending this chunk
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is used to connect a (typically remote) store with a local store which functions as disk cache. Any request to the cache for a chunk will first be routed to the local store, and if that fails to the slower remote store. Any chunks retrieved from the remote store will be stored in the local one.
func NewCache ¶
func NewCache(s Store, l LocalStore) Cache
NewCache returns a cache router that uses a local store as cache before accessing a (supposedly slower) remote one.
type Caibx ¶
type Caibx struct { Index Index Header Header Chunks []BlobIndexChunk }
Caibx represents the content of a caibx file
type ChunkID ¶
type ChunkID [32]byte
ChunkID is the SHA512/256 in binary encoding
func ChunkIDFromSlice ¶
ChunkIDFromSlice converts a SHA512/256 encoded as byte slice into a ChunkID. It's expected the slice is of the correct length
func ChunkIDFromString ¶
ChunkIDFromString converts a SHA512/56 encoded as string into a ChunkID
type ChunkMissing ¶
type ChunkMissing struct {
ID ChunkID
}
ChunkMissing is returned by a store that can't find a requested chunk
func (ChunkMissing) Error ¶
func (e ChunkMissing) Error() string
type Index ¶
type Index struct { Size uint64 Type uint64 Flags uint64 ChunkSizeMin uint64 ChunkSizeAvg uint64 ChunkSizeMax uint64 }
Index at the start of the caibx file
type LocalStore ¶
type LocalStore struct { Base string // When accessing chunks, should mtime be updated? Useful when this is // a cache. Old chunks can be identified and removed from the store that way UpdateTimes bool }
LocalStore casync store
func NewLocalStore ¶
func NewLocalStore(dir string) (LocalStore, error)
NewLocalStore creates an instance of a local castore, it only checks presence of the store
func (LocalStore) GetChunk ¶
func (s LocalStore) GetChunk(id ChunkID) ([]byte, error)
GetChunk reads and returns one (compressed!) chunk from the store
func (LocalStore) StoreChunk ¶
func (s LocalStore) StoreChunk(id ChunkID, b []byte) error
StoreChunk adds a new chunk to the store
type RemoteSSH ¶
type RemoteSSH struct {
// contains filtered or unexported fields
}
RemoteSSH is a remote casync store accessed via SSH. Supports running multiple sessions to improve throughput.
func NewRemoteSSHStore ¶
NewRemoteSSHStore establishes up to n connections with a casync chunk server
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents one instance of a local SSH client and a remote casync store server. TODO: There's currently no way to stop a session, we just rely on the process terminating and cleaning up everything.
func StartSession ¶
StartSession initiates a connection to the remote store server using the value in CASYNC_SSH_PATH (default "ssh"), and executes the command in CASYNC_REMOTE_PATH (default "casync"). It then performs the HELLO handshake to initialze the connection before returning a Session object that can then be used to request chunks.
func (Session) ReadMessage ¶
ReadMessage reads a generic message from the server, verifies the length, extracts the type and returns the message body as byte slice
func (Session) RecvHello ¶
RecvHello waits for the server to send a HELLO, fails if anything else is received. Returns the flags provided by the server.
func (Session) RequestChunk ¶
RequestChunk sends a request for a specific chunk to the server, waits for the response and returns the bytes in the chunk. Returns an error if the server reports the chunk as missing
func (Session) SendHello ¶
SendHello sends a HELLO message to the server, with the flags signaling which service is being requested from it.
func (Session) SendProtocolRequest ¶
func (Session) WriteMessage ¶
WriteMessage sends a generic message to the server