Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileReader ¶
type FileReader struct {
// contains filtered or unexported fields
}
FileReader is the common code to read the storages until the subscription channel is closed
type FileStorage ¶
type FileStorage struct {
// contains filtered or unexported fields
}
FileStorage saves the content into a file
func (*FileStorage) GetReader ¶
func (f *FileStorage) GetReader() (io.ReadCloser, error)
GetReader returns a new file descriptor to the same file
type NoStorage ¶
type NoStorage struct {
// contains filtered or unexported fields
}
NoStorage writes the content directly into the ResponseWriter TODO remove this
type ResponseStorage ¶
type ResponseStorage interface { io.Writer io.Closer Clean() error Flush() error GetReader() (io.ReadCloser, error) }
ResponseStorage represents a possible storage for the entry
func NewFileStorage ¶
func NewFileStorage(path string) (ResponseStorage, error)
NewFileStorage creates a new temp file that will be used as a the storage of the cache entry
func WrapResponseWriter ¶
func WrapResponseWriter(w http.ResponseWriter) ResponseStorage
WrapResponseWriter wraps an http.ResponseWriter and gives it the ResponseStorage interface
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription is a structure to sync all File Readers in a pub/sub style. It's useful when there are many readers that want to read from a single writter. The writter can create a subscription and give each other a NewSubscriber(). Each time the producer call NotifyAll the clients will get a channel with the value. In case a client blocks it will miss the next reads that will not be queued.
func NewSubscription ¶
func NewSubscription() *Subscription
func (*Subscription) Close ¶
func (s *Subscription) Close()
func (*Subscription) NewSubscriber ¶
func (s *Subscription) NewSubscriber() <-chan int
func (*Subscription) NotifyAll ¶
func (s *Subscription) NotifyAll(newBytes int)
func (*Subscription) RemoveSubscriber ¶
func (s *Subscription) RemoveSubscriber(subscriber <-chan int)
func (*Subscription) WaitAll ¶
func (s *Subscription) WaitAll()
WaitAll waits until are subscribers ends