cba

package
v0.0.0-...-4b497b0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2014 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashPath

func HashPath(dir string, hash string) string

func ReadHexDatabase

func ReadHexDatabase(d string) map[string]bool

Types

type Client

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

Client is a thread-safe interface to fetching over a connection.

func (*Client) Close

func (c *Client) Close()

func (*Client) Fetch

func (c *Client) Fetch(want string, size int64) (bool, error)

func (*Client) FetchOnce

func (c *Client) FetchOnce(want string, size int64) (bool, error)

FetchOnce makes sure only one fetch is done, if concurrent fetches for the same file happen.

type HashWriter

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

func (*HashWriter) Close

func (st *HashWriter) Close() error

func (*HashWriter) CopyClose

func (st *HashWriter) CopyClose(input io.Reader, size int64) error

func (*HashWriter) Sum

func (st *HashWriter) Sum() string

func (*HashWriter) Write

func (st *HashWriter) Write(p []byte) (n int, err error)

func (*HashWriter) WriteClose

func (st *HashWriter) WriteClose(p []byte) (err error)

type LruCache

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

A fixed entry count cache with LRU eviction policy.

Should be protected by a Mutex (not RWMutex) for all methods.

func NewLruCache

func NewLruCache(size int) (me *LruCache)

func (*LruCache) Add

func (me *LruCache) Add(key string, val interface{})

func (*LruCache) AverageAge

func (me *LruCache) AverageAge() int

func (*LruCache) Get

func (me *LruCache) Get(key string) (val interface{})

func (*LruCache) Has

func (me *LruCache) Has(key string) bool

func (*LruCache) Size

func (me *LruCache) Size() int

type Request

type Request struct {
	Hash  string
	Start int
}

func (*Request) String

func (me *Request) String() string

type Response

type Response struct {
	Size  int
	Have  bool
	Last  bool
	Chunk []byte
}

type ServeSplice

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

type Server

type Server interface {
	ServeChunk(req *Request, rep *Response) (err error)
	Close()
}

type Store

type Store struct {
	// Should not change option values after initalizing.
	Options *StoreOptions
	// contains filtered or unexported fields
}

Content based addressing cache.

func NewStore

func NewStore(options *StoreOptions, timings *stats.TimerStats) *Store

NewStore creates a content cache based in directory d. memorySize sets the maximum number of file contents to keep in memory.

func (*Store) AddTiming

func (st *Store) AddTiming(name string, bytes int, dt time.Duration)

func (*Store) DestructiveSavePath

func (st *Store) DestructiveSavePath(path string) (hash string, err error)

func (*Store) Has

func (st *Store) Has(hash string) bool

func (*Store) HashType

func (st *Store) HashType() crypto.Hash

func (*Store) NewClient

func (store *Store) NewClient(conn io.ReadWriteCloser) *Client

func (*Store) NewHashWriter

func (store *Store) NewHashWriter() *HashWriter

func (*Store) Path

func (st *Store) Path(hash string) string

func (*Store) Save

func (st *Store) Save(content []byte) (hash string)

func (*Store) SavePath

func (st *Store) SavePath(path string) (hash string)

func (*Store) SaveStream

func (st *Store) SaveStream(input io.Reader, size int64) (hash string)

func (*Store) ServeChunk

func (st *Store) ServeChunk(req *Request, rep *Response) (err error)

func (*Store) ServeConn

func (c *Store) ServeConn(conn io.ReadWriteCloser)

func (*Store) ThroughputStats

func (st *Store) ThroughputStats() []stats.Sample

type StoreOptions

type StoreOptions struct {
	Hash crypto.Hash
	Dir  string
}

type ThroughputSample

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

func (*ThroughputSample) AddSample

func (s *ThroughputSample) AddSample(r stats.Sample)

func (*ThroughputSample) CopySample

func (s *ThroughputSample) CopySample() stats.Sample

func (*ThroughputSample) String

func (s *ThroughputSample) String() string

func (*ThroughputSample) SubtractSample

func (s *ThroughputSample) SubtractSample(r stats.Sample)

func (*ThroughputSample) TableHeader

func (s *ThroughputSample) TableHeader() string

func (*ThroughputSample) TableRow

func (s *ThroughputSample) TableRow() string

Jump to

Keyboard shortcuts

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