services

package
v0.0.0-...-af82944 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PRELOAD_TTL                      = 10
	PRELOAD_TIMEOUT                  = 60
	PRELOAD_CACHE_PATH               = "cache"
	PRELOAD_CLEAR_CACHE_ON_EXIT_FLAG = "preload-clear-cache-on-exit"
	PRELOAD_CACHE_SIZE_FLAG          = "preload-cache-size"
)
View Source
const (
	AWS_BUCKET        = "aws-bucket"
	AWS_BUCKET_SPREAD = "aws-bucket-spread"
)
View Source
const (
	WEB_HOST_FLAG  = "host"
	WEB_PORT_FLAG  = "port"
	WEB_SOURCE_URL = "source-url"
)
View Source
const (
	COMPLETED_PIECES_TTL = 300
)
View Source
const (
	MAX_PRELOAD_BYTES = 30_000_000
)
View Source
const (
	META_INFO_TTL = 60
)
View Source
const (
	PRELOAD_QUEUE_CONCURRENCY = 3
)
View Source
const (
	PRELOAD_QUEUE_TTL = 60
)
View Source
const (
	TORRENT_TOUCH_TTL = 600
)

Variables

This section is empty.

Functions

func RegisterPreloadFlags

func RegisterPreloadFlags(c *cli.App)

func RegisterS3StorageFlags

func RegisterS3StorageFlags(c *cli.App)

func RegisterWebFlags

func RegisterWebFlags(c *cli.App)

Types

type CompletedPieces

type CompletedPieces map[[20]byte]bool

func (CompletedPieces) Add

func (cp CompletedPieces) Add(h [20]byte)

func (CompletedPieces) FromBytes

func (cp CompletedPieces) FromBytes(data []byte)

func (CompletedPieces) Has

func (cp CompletedPieces) Has(h [20]byte) bool

func (CompletedPieces) HasHex

func (cp CompletedPieces) HasHex(h string) (bool, error)

func (CompletedPieces) Load

func (cp CompletedPieces) Load(r io.Reader) error

func (CompletedPieces) ToBytes

func (cp CompletedPieces) ToBytes() []byte

type CompletedPiecesLoader

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

func NewCompletedPiecesLoader

func NewCompletedPiecesLoader(ctx context.Context, infoHash string, st *S3Storage) *CompletedPiecesLoader

func (*CompletedPiecesLoader) Get

type CompletedPiecesPool

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

func NewCompletedPiecesPool

func NewCompletedPiecesPool(st *S3Storage) *CompletedPiecesPool

func (*CompletedPiecesPool) Get

type HTTPPieceLoader

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

func NewHTTPPieceLoader

func NewHTTPPieceLoader(ctx context.Context, cl *http.Client, src string, h string, p string, q string, start int64, end int64, full bool) *HTTPPieceLoader

func (*HTTPPieceLoader) Get

func (s *HTTPPieceLoader) Get() (io.ReadCloser, error)

type HTTPPiecePool

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

func NewHTTPPiecePool

func NewHTTPPiecePool(cl *http.Client) *HTTPPiecePool

func (*HTTPPiecePool) Get

func (s *HTTPPiecePool) Get(ctx context.Context, src string, h string, p string, q string, start int64, end int64, full bool) (io.ReadCloser, error)

type HTTPProxyMap

type HTTPProxyMap struct {
	lazymap.LazyMap
}

func NewHTTPProxyMap

func NewHTTPProxyMap() *HTTPProxyMap

func (*HTTPProxyMap) Get

type LeakyBuffer

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

func NewLeakyBuffer

func NewLeakyBuffer(size int, bufSize int64) *LeakyBuffer

func (*LeakyBuffer) Get

func (s *LeakyBuffer) Get() []byte

func (*LeakyBuffer) Put

func (s *LeakyBuffer) Put(b []byte)

type MetaInfoLoader

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

func NewMetaInfoLoader

func NewMetaInfoLoader(ctx context.Context, infoHash string, st *S3Storage) *MetaInfoLoader

func (*MetaInfoLoader) Get

func (s *MetaInfoLoader) Get() (*metainfo.Info, error)

type MetaInfoPool

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

func NewMetaInfoPool

func NewMetaInfoPool(st *S3Storage) *MetaInfoPool

func (*MetaInfoPool) Get

func (s *MetaInfoPool) Get(h string) (*metainfo.Info, error)

type PieceLoader

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

func NewPieceLoader

func NewPieceLoader(ctx context.Context, cpp *CompletedPiecesPool, s3pp *S3PiecePool,
	httppp *HTTPPiecePool, src string, h string, p string, q string, start int64, end int64, full bool) *PieceLoader

func (*PieceLoader) Get

func (s *PieceLoader) Get() (io.ReadCloser, error)

type PiecePool

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

func NewPiecePool

func NewPiecePool(cpp *CompletedPiecesPool, s3pp *S3PiecePool,
	httppp *HTTPPiecePool) *PiecePool

func (*PiecePool) Get

func (s *PiecePool) Get(ctx context.Context, src string, h string, p string, q string, start int64, end int64, full bool) (io.ReadCloser, error)

type PiecePreloader

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

func NewPiecePreloader

func NewPiecePreloader(ctx context.Context, pp *PiecePool, lb *LeakyBuffer, src string, h string, p string, q string) *PiecePreloader

func (*PiecePreloader) Clean

func (s *PiecePreloader) Clean() error

func (*PiecePreloader) Get

func (s *PiecePreloader) Get(start int64, end int64, full bool) (io.ReadCloser, error)

func (*PiecePreloader) Preload

func (s *PiecePreloader) Preload() error

type PreloadPiecePool

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

func NewPreloadPiecePool

func NewPreloadPiecePool(c *cli.Context, pp *PiecePool, lb *LeakyBuffer) (*PreloadPiecePool, error)

func (*PreloadPiecePool) Close

func (s *PreloadPiecePool) Close()

func (*PreloadPiecePool) Get

func (s *PreloadPiecePool) Get(ctx context.Context, src string, h string, p string, q string, start int64, end int64, full bool) (io.ReadCloser, error)

func (*PreloadPiecePool) Preload

func (s *PreloadPiecePool) Preload(src string, h string, p string, q string)

type PreloadQueue

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

func NewPreloadQueue

func NewPreloadQueue(pp *PreloadPiecePool) *PreloadQueue

func (*PreloadQueue) Close

func (s *PreloadQueue) Close()

func (*PreloadQueue) Push

func (s *PreloadQueue) Push(src string, h string, p string, q string)

type PreloadQueuePool

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

func NewPreloadQueuePool

func NewPreloadQueuePool(pp *PreloadPiecePool) *PreloadQueuePool

func (*PreloadQueuePool) Push

func (s *PreloadQueuePool) Push(key string, src string, h string, p string, q string)

type PreloadReader

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

func NewPreloadReader

func NewPreloadReader(f *os.File, r io.Reader, lb *LeakyBuffer, h string, p string) *PreloadReader

func (*PreloadReader) Close

func (s *PreloadReader) Close() error

func (*PreloadReader) Read

func (s *PreloadReader) Read(p []byte) (n int, err error)

func (*PreloadReader) WriteTo

func (r *PreloadReader) WriteTo(w io.Writer) (n int64, err error)

type RWConnector

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

func NewRWConnector

func NewRWConnector(w http.ResponseWriter, lb *LeakyBuffer) *RWConnector

func (*RWConnector) CloseNotify

func (s *RWConnector) CloseNotify() <-chan bool

func (*RWConnector) Flush

func (s *RWConnector) Flush()

func (*RWConnector) Header

func (s *RWConnector) Header() http.Header

func (*RWConnector) ReadFrom

func (s *RWConnector) ReadFrom(r io.Reader) (n int64, err error)

func (*RWConnector) Write

func (s *RWConnector) Write(p []byte) (n int, err error)

func (*RWConnector) WriteHeader

func (s *RWConnector) WriteHeader(statusCode int)

type Reader

type Reader struct {
	N int64
	// contains filtered or unexported fields
}

func NewReader

func NewReader(ctx context.Context, mip *MetaInfoPool, pp *PreloadPiecePool, ttp *TorrentTouchPool, lb *LeakyBuffer, pqp *PreloadQueuePool, src string, hash string, query string, offset int64, length int64, pid string) *Reader

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) Read

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

func (*Reader) Ready

func (r *Reader) Ready() (bool, error)

func (*Reader) Seek

func (r *Reader) Seek(offset int64, whence int) (int64, error)

func (*Reader) WriteTo

func (r *Reader) WriteTo(w io.Writer) (n int64, err error)

type ReaderPool

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

func (*ReaderPool) Get

func (rp *ReaderPool) Get(ctx context.Context, s string, piece string, pid string) (*Reader, *url.URL, string, string, error)

type S3PieceLoader

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

func NewS3PieceLoader

func NewS3PieceLoader(ctx context.Context, infoHash string, pieceHash string, st *S3Storage, start int64, end int64, full bool) *S3PieceLoader

func (*S3PieceLoader) Get

func (s *S3PieceLoader) Get() (io.ReadCloser, error)

type S3PiecePool

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

func NewS3PiecePool

func NewS3PiecePool(st *S3Storage) *S3PiecePool

func (*S3PiecePool) Get

func (s *S3PiecePool) Get(ctx context.Context, h string, p string, start int64, end int64, full bool) (io.ReadCloser, error)

type S3Storage

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

func NewS3Storage

func NewS3Storage(c *cli.Context, cl *cs.S3Client) *S3Storage

func (*S3Storage) GetCompletedPieces

func (s *S3Storage) GetCompletedPieces(ctx context.Context, h string) (io.ReadCloser, error)

func (*S3Storage) GetPiece

func (s *S3Storage) GetPiece(ctx context.Context, h string, p string, start int64, end int64, full bool) (io.ReadCloser, error)

func (*S3Storage) GetTorrent

func (s *S3Storage) GetTorrent(ctx context.Context, h string) (io.ReadCloser, error)

func (*S3Storage) TouchTorrent

func (s *S3Storage) TouchTorrent(ctx context.Context, h string) (err error)

type TimerWrapper

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

func NewTimerWrapper

func NewTimerWrapper(d time.Duration) *TimerWrapper

func (*TimerWrapper) Get

func (s *TimerWrapper) Get() *time.Timer

type TorrentTouchPool

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

func NewTorrentTouchPool

func NewTorrentTouchPool(st *S3Storage) *TorrentTouchPool

func (*TorrentTouchPool) Touch

func (s *TorrentTouchPool) Touch(h string) error

type TorrentToucher

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

func NewTorrentToucher

func NewTorrentToucher(ctx context.Context, infoHash string, st *S3Storage) *TorrentToucher

func (*TorrentToucher) Touch

func (s *TorrentToucher) Touch() error

type Web

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

func NewWeb

func NewWeb(c *cli.Context, rp *ReaderPool, cp *CompletedPiecesPool, lb *LeakyBuffer, pm *HTTPProxyMap) *Web

func (*Web) Close

func (s *Web) Close()

func (*Web) Serve

func (s *Web) Serve() error

Jump to

Keyboard shortcuts

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