storage

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2017 License: LGPL-3.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func (*FileReader) Close

func (r *FileReader) Close() error

Close closes the underlying storage

func (*FileReader) Read

func (r *FileReader) Read(p []byte) (n int, err error)

type FileStorage

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

FileStorage saves the content into a file

func (*FileStorage) Clean

func (f *FileStorage) Clean() error

Clean removes the file

func (*FileStorage) Close

func (f *FileStorage) Close() error

Close the underlying file

func (*FileStorage) Flush

func (f *FileStorage) Flush() error

Flush syncs the underlying file

func (*FileStorage) GetReader

func (f *FileStorage) GetReader() (io.ReadCloser, error)

GetReader returns a new file descriptor to the same file

func (*FileStorage) Write

func (f *FileStorage) Write(p []byte) (n int, err error)

type NoStorage

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

NoStorage writes the content directly into the ResponseWriter TODO remove this

func (*NoStorage) Clean

func (b *NoStorage) Clean() error

Clean does nothing in the buffer it will be garbage collected eventually

func (*NoStorage) Close

func (b *NoStorage) Close() error

Close the storage entry

func (*NoStorage) Flush

func (b *NoStorage) Flush() error

Flush does nothing in a buffer

func (*NoStorage) GetReader

func (b *NoStorage) GetReader() (io.ReadCloser, error)

GetReader returns the same buffer

func (*NoStorage) Write

func (b *NoStorage) Write(p []byte) (n int, err error)

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
}

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

Jump to

Keyboard shortcuts

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