Documentation ¶
Index ¶
- Constants
- func AssertChunkContents(t *testing.T, chunks ChunkDB, id, want string)
- func AssertChunkDoesntExists(t *testing.T, chunks ChunkDB, id string)
- func AssertReceivedChunkCalls(t *testing.T, nsConn *SpyNSConnector, ids ...string)
- func AssertResponseBody(t *testing.T, got, want string)
- func AssertStatus(t *testing.T, got, want int)
- func NewCancelTokenRequest(token string) *http.Request
- func NewExpectRequest(action, token string, chunks ...string) *http.Request
- func NewGetChunkRequest(id, token string) *http.Request
- func NewPostChunkRequest(id, content, token string) *http.Request
- func NewProbeRequest(remoteAddr string) *http.Request
- func NewPurgeRequest(chunks ...string) *http.Request
- func NewReplicateRequest(addr, token string, chunks ...string) *http.Request
- type ChunkDB
- type ChunkError
- type ConfigurableSleeper
- type ExpectAction
- type ExpectationDB
- type FSProbeInfo
- type FileServer
- func (s *FileServer) CancelTokenHandler(w http.ResponseWriter, r *http.Request)
- func (s *FileServer) Expect(token string, action ExpectAction, chunks ...string) error
- func (s *FileServer) ExpectHandler(w http.ResponseWriter, r *http.Request)
- func (s *FileServer) GenerateProbeInfo() *FSProbeInfo
- func (s *FileServer) GetTokenExpectationForChunk(token, id string) ExpectAction
- func (s *FileServer) ProbeHandler(w http.ResponseWriter, r *http.Request)
- func (s *FileServer) PurgeHandler(w http.ResponseWriter, r *http.Request)
- func (s *FileServer) ReceiveChunk(w http.ResponseWriter, r *http.Request, id, token string)
- func (s *FileServer) ReplicateHandler(w http.ResponseWriter, r *http.Request)
- func (s *FileServer) SendChunk(w http.ResponseWriter, r *http.Request, id, token string)
- func (cs *FileServer) ServeClient(w http.ResponseWriter, r *http.Request)
- func (s *FileServer) ServeNS(w http.ResponseWriter, r *http.Request)
- type FileSystemChunkStorage
- func (s *FileSystemChunkStorage) BytesAvailable() int
- func (s *FileSystemChunkStorage) Create(id string) (io.Writer, func(), error)
- func (s *FileSystemChunkStorage) Exists(id string) bool
- func (s *FileSystemChunkStorage) Get(id string) (io.Reader, func(), error)
- func (s *FileSystemChunkStorage) Remove(id string) error
- type HTTPNSConnector
- type HTTPPoller
- type Heart
- type InMemoryChunkStorage
- func (s *InMemoryChunkStorage) BytesAvailable() int
- func (s *InMemoryChunkStorage) Create(id string) (io.Writer, func(), error)
- func (s *InMemoryChunkStorage) Exists(id string) (exists bool)
- func (s *InMemoryChunkStorage) Get(id string) (io.Reader, func(), error)
- func (s *InMemoryChunkStorage) Remove(id string) error
- type NSConnector
- type Poller
- type Sleeper
- type SpyNSConnector
- type SpyPoller
- type SpySleeper
- type SpySleeperTime
- type TokenExpectation
Constants ¶
View Source
const ( ErrChunkExists = ChunkError("chunk already exists") ErrChunkNotFound = ChunkError("chunk does not exists") )
View Source
const ( ExpectActionNothing = ExpectAction(0) ExpectActionRead = ExpectAction(1) ExpectActionWrite = ExpectAction(2) )
View Source
const NSPORT = ":7071"
Variables ¶
This section is empty.
Functions ¶
func AssertChunkDoesntExists ¶
func AssertReceivedChunkCalls ¶
func AssertReceivedChunkCalls(t *testing.T, nsConn *SpyNSConnector, ids ...string)
func AssertResponseBody ¶
func AssertStatus ¶
func NewCancelTokenRequest ¶
func NewGetChunkRequest ¶
func NewPostChunkRequest ¶
func NewProbeRequest ¶
func NewPurgeRequest ¶
Types ¶
type ChunkError ¶
type ChunkError string
func (ChunkError) Error ¶
func (c ChunkError) Error() string
type ConfigurableSleeper ¶
func (*ConfigurableSleeper) Sleep ¶
func (s *ConfigurableSleeper) Sleep()
type ExpectAction ¶
type ExpectAction int
type ExpectationDB ¶
type ExpectationDB struct {
// contains filtered or unexported fields
}
func NewExpectationDB ¶
func NewExpectationDB() *ExpectationDB
func (*ExpectationDB) Get ¶
func (e *ExpectationDB) Get(token string) *TokenExpectation
func (*ExpectationDB) MakeObsolete ¶
func (e *ExpectationDB) MakeObsolete(chunks ...string) (toPurge []string)
func (*ExpectationDB) Remove ¶
func (e *ExpectationDB) Remove(token string) []string
func (*ExpectationDB) Set ¶
func (e *ExpectationDB) Set(token string, exp *TokenExpectation)
type FSProbeInfo ¶
type FSProbeInfo struct {
Available int
}
type FileServer ¶
type FileServer struct {
// contains filtered or unexported fields
}
func NewFileServer ¶
func NewFileServer(store ChunkDB, nsConn NSConnector) (s *FileServer)
func (*FileServer) CancelTokenHandler ¶
func (s *FileServer) CancelTokenHandler(w http.ResponseWriter, r *http.Request)
func (*FileServer) Expect ¶
func (s *FileServer) Expect(token string, action ExpectAction, chunks ...string) error
func (*FileServer) ExpectHandler ¶
func (s *FileServer) ExpectHandler(w http.ResponseWriter, r *http.Request)
func (*FileServer) GenerateProbeInfo ¶
func (s *FileServer) GenerateProbeInfo() *FSProbeInfo
func (*FileServer) GetTokenExpectationForChunk ¶
func (s *FileServer) GetTokenExpectationForChunk(token, id string) ExpectAction
func (*FileServer) ProbeHandler ¶
func (s *FileServer) ProbeHandler(w http.ResponseWriter, r *http.Request)
func (*FileServer) PurgeHandler ¶
func (s *FileServer) PurgeHandler(w http.ResponseWriter, r *http.Request)
func (*FileServer) ReceiveChunk ¶
func (s *FileServer) ReceiveChunk(w http.ResponseWriter, r *http.Request, id, token string)
func (*FileServer) ReplicateHandler ¶
func (s *FileServer) ReplicateHandler(w http.ResponseWriter, r *http.Request)
func (*FileServer) SendChunk ¶
func (s *FileServer) SendChunk(w http.ResponseWriter, r *http.Request, id, token string)
func (*FileServer) ServeClient ¶
func (cs *FileServer) ServeClient(w http.ResponseWriter, r *http.Request)
func (*FileServer) ServeNS ¶
func (s *FileServer) ServeNS(w http.ResponseWriter, r *http.Request)
type FileSystemChunkStorage ¶
type FileSystemChunkStorage struct { Dir string // contains filtered or unexported fields }
func NewFileSystemChunkStorage ¶
func NewFileSystemChunkStorage(dir string) (*FileSystemChunkStorage, error)
func (*FileSystemChunkStorage) BytesAvailable ¶
func (s *FileSystemChunkStorage) BytesAvailable() int
func (*FileSystemChunkStorage) Create ¶
func (s *FileSystemChunkStorage) Create(id string) (io.Writer, func(), error)
func (*FileSystemChunkStorage) Exists ¶
func (s *FileSystemChunkStorage) Exists(id string) bool
func (*FileSystemChunkStorage) Get ¶
func (s *FileSystemChunkStorage) Get(id string) (io.Reader, func(), error)
func (*FileSystemChunkStorage) Remove ¶
func (s *FileSystemChunkStorage) Remove(id string) error
type HTTPNSConnector ¶
type HTTPNSConnector struct { Addr string // contains filtered or unexported fields }
func (*HTTPNSConnector) GetNSAddr ¶
func (c *HTTPNSConnector) GetNSAddr() string
func (*HTTPNSConnector) IsNS ¶
func (c *HTTPNSConnector) IsNS(addr string) bool
func (*HTTPNSConnector) Poll ¶
func (c *HTTPNSConnector) Poll()
func (*HTTPNSConnector) ReceivedChunk ¶
func (c *HTTPNSConnector) ReceivedChunk(id string)
func (*HTTPNSConnector) SetNSAddr ¶
func (c *HTTPNSConnector) SetNSAddr(addr string)
type HTTPPoller ¶
type HTTPPoller struct {
// contains filtered or unexported fields
}
HTTPPoller will poll the specified URL link. The link should contain http:// at the beginning.
func (*HTTPPoller) Poll ¶
func (p *HTTPPoller) Poll()
type InMemoryChunkStorage ¶
type InMemoryChunkStorage struct { Index map[string]string Mu sync.RWMutex // contains filtered or unexported fields }
func NewInMemoryChunkStorage ¶
func NewInMemoryChunkStorage(index map[string]string) *InMemoryChunkStorage
func (*InMemoryChunkStorage) BytesAvailable ¶
func (s *InMemoryChunkStorage) BytesAvailable() int
func (*InMemoryChunkStorage) Create ¶
func (s *InMemoryChunkStorage) Create(id string) (io.Writer, func(), error)
func (*InMemoryChunkStorage) Exists ¶
func (s *InMemoryChunkStorage) Exists(id string) (exists bool)
func (*InMemoryChunkStorage) Get ¶
func (s *InMemoryChunkStorage) Get(id string) (io.Reader, func(), error)
func (*InMemoryChunkStorage) Remove ¶
func (s *InMemoryChunkStorage) Remove(id string) error
type NSConnector ¶
type SpyNSConnector ¶
func (*SpyNSConnector) GetNSAddr ¶
func (c *SpyNSConnector) GetNSAddr() string
func (*SpyNSConnector) IsNS ¶
func (c *SpyNSConnector) IsNS(addr string) bool
func (*SpyNSConnector) Poll ¶
func (c *SpyNSConnector) Poll()
func (*SpyNSConnector) ReceivedChunk ¶
func (c *SpyNSConnector) ReceivedChunk(id string)
func (*SpyNSConnector) Reset ¶
func (c *SpyNSConnector) Reset()
func (*SpyNSConnector) SetNSAddr ¶
func (c *SpyNSConnector) SetNSAddr(addr string)
type SpySleeper ¶
type SpySleeper struct {
CallCount int
}
func (*SpySleeper) Sleep ¶
func (s *SpySleeper) Sleep()
type SpySleeperTime ¶
func (*SpySleeperTime) Sleep ¶
func (s *SpySleeperTime) Sleep(duration time.Duration)
type TokenExpectation ¶
type TokenExpectation struct {
// contains filtered or unexported fields
}
token -> chunkId -> ExpectAction Putting token first makes it more cache-friendly, since there much less tokens than chunks. type TokenExpectations map[string]map[string]ExpectAction
Source Files ¶
Click to show internal directories.
Click to hide internal directories.