agentstorage

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: Apache-2.0 Imports: 17 Imported by: 2

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.

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

This section is empty.

Functions

This section is empty.

Types

type Torrent

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

Torrent implements a Torrent on top of an AgentFileStore. It Allows concurrent writes on distinct pieces, and concurrent reads on all pieces. Behavior is undefined if multiple Torrent instances are backed by the same file store and metainfo.

func NewTorrent

func NewTorrent(cads caDownloadStore, mi *core.MetaInfo) (*Torrent, error)

NewTorrent creates a new Torrent.

func TorrentFixture

func TorrentFixture(mi *core.MetaInfo) (*Torrent, func())

TorrentFixture returns a Torrent for the given metainfo for testing purposes.

func (*Torrent) Bitfield

func (t *Torrent) Bitfield() *bitset.BitSet

Bitfield returns the bitfield of pieces where true denotes a complete piece and false denotes an incomplete piece.

func (*Torrent) BytesDownloaded

func (t *Torrent) BytesDownloaded() int64

BytesDownloaded returns an estimate of the number of bytes downloaded in the torrent.

func (*Torrent) Complete

func (t *Torrent) Complete() bool

Complete indicates whether the torrent is complete or not. Completeness is defined by whether the torrent file has been committed to the cache directory.

func (*Torrent) Digest

func (t *Torrent) Digest() core.Digest

Digest returns the digest of the target blob.

func (*Torrent) GetPieceReader

func (t *Torrent) GetPieceReader(pi int) (storage.PieceReader, error)

GetPieceReader returns a reader for piece pi.

func (*Torrent) HasPiece

func (t *Torrent) HasPiece(pi int) bool

HasPiece returns if piece pi is complete.

func (*Torrent) InfoHash

func (t *Torrent) InfoHash() core.InfoHash

InfoHash returns the torrent metainfo hash.

func (*Torrent) Length

func (t *Torrent) Length() int64

Length returns the length of the target file.

func (*Torrent) MaxPieceLength

func (t *Torrent) MaxPieceLength() int64

MaxPieceLength returns the longest piece length of the torrent.

func (*Torrent) MissingPieces

func (t *Torrent) MissingPieces() []int

MissingPieces returns the indeces of all missing pieces.

func (*Torrent) NumPieces

func (t *Torrent) NumPieces() int

NumPieces returns the number of pieces in the torrent.

func (*Torrent) PieceLength

func (t *Torrent) PieceLength(pi int) int64

PieceLength returns the length of piece pi.

func (*Torrent) Stat

func (t *Torrent) Stat() *storage.TorrentInfo

Stat returns the storage.TorrentInfo for t.

func (*Torrent) String

func (t *Torrent) String() string

func (*Torrent) WritePiece

func (t *Torrent) WritePiece(src storage.PieceReader, pi int) error

WritePiece writes data to piece pi.

type TorrentArchive

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

TorrentArchive is capable of initializing torrents in the download directory and serving torrents from either the download or cache directory.

func NewTorrentArchive

func NewTorrentArchive(
	stats tally.Scope,
	cads *store.CADownloadStore,
	mic metainfoclient.Client) *TorrentArchive

NewTorrentArchive creates a new TorrentArchive.

func TorrentArchiveFixture

func TorrentArchiveFixture() (*TorrentArchive, func())

TorrentArchiveFixture returns a TorrrentArchive for testing purposes.

func (*TorrentArchive) CreateTorrent

func (a *TorrentArchive) CreateTorrent(namespace string, d core.Digest) (storage.Torrent, error)

CreateTorrent returns a Torrent for either an existing metainfo / file on disk, or downloads metainfo and initializes the file. Returns ErrNotFound if no metainfo was found.

func (*TorrentArchive) DeleteTorrent

func (a *TorrentArchive) DeleteTorrent(d core.Digest) error

DeleteTorrent deletes a torrent from disk.

func (*TorrentArchive) GetTorrent

func (a *TorrentArchive) GetTorrent(namespace string, d core.Digest) (storage.Torrent, error)

GetTorrent returns a Torrent for an existing metainfo / file on disk. Ignores namespace.

func (*TorrentArchive) Stat

func (a *TorrentArchive) Stat(namespace string, d core.Digest) (*storage.TorrentInfo, error)

Stat returns TorrentInfo for the given digest. Returns os.ErrNotExist if the file does not exist. Ignores namespace.

Jump to

Keyboard shortcuts

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