storage

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("torrent not found")

ErrNotFound occurs when TorrentArchive cannot found a torrent.

View Source
var ErrPieceComplete = errors.New("piece is already complete")

ErrPieceComplete occurs when Torrent cannot write a piece because it is already complete.

Functions

This section is empty.

Types

type PieceReader

type PieceReader interface {
	io.ReadCloser
	Length() int
}

PieceReader defines operations for lazy piece reading.

type Torrent

type Torrent interface {
	Digest() core.Digest
	Stat() *TorrentInfo
	NumPieces() int
	Length() int64
	PieceLength(piece int) int64
	MaxPieceLength() int64
	InfoHash() core.InfoHash
	Complete() bool
	BytesDownloaded() int64
	Bitfield() *bitset.BitSet
	String() string

	HasPiece(piece int) bool
	MissingPieces() []int

	WritePiece(src PieceReader, piece int) error
	GetPieceReader(piece int) (PieceReader, error)
}

Torrent represents a read/write interface for a torrent

type TorrentArchive

type TorrentArchive interface {
	Stat(namespace string, d core.Digest) (*TorrentInfo, error)
	CreateTorrent(namespace string, d core.Digest) (Torrent, error)
	GetTorrent(namespace string, d core.Digest) (Torrent, error)
	DeleteTorrent(d core.Digest) error
}

TorrentArchive creates and open torrent file

type TorrentInfo

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

TorrentInfo encapsulates read-only torrent information.

func NewTorrentInfo

func NewTorrentInfo(mi *core.MetaInfo, bitfield *bitset.BitSet) *TorrentInfo

NewTorrentInfo creates a new TorrentInfo.

func TorrentInfoFixture

func TorrentInfoFixture(size, pieceLength uint64) *TorrentInfo

TorrentInfoFixture returns a randomly generated TorrentInfo for testing purposes.

func (*TorrentInfo) Bitfield

func (i *TorrentInfo) Bitfield() *bitset.BitSet

Bitfield returns the piece status bitfield of the torrent. Note, this is a snapshot and may be stale information.

func (*TorrentInfo) Digest

func (i *TorrentInfo) Digest() core.Digest

Digest returns the torrent's blob digest.

func (*TorrentInfo) InfoHash

func (i *TorrentInfo) InfoHash() core.InfoHash

InfoHash returns the hash torrent metainfo.

func (*TorrentInfo) MaxPieceLength

func (i *TorrentInfo) MaxPieceLength() int64

MaxPieceLength returns the max piece length of the torrent.

func (*TorrentInfo) PercentDownloaded

func (i *TorrentInfo) PercentDownloaded() int

PercentDownloaded returns the percent of bytes downloaded as an integer between 0 and 100. Useful for logging.

func (*TorrentInfo) String

func (i *TorrentInfo) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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