client

package
v0.0.0-...-95cd7cf Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownRegion means that the region is invalid.
	ErrUnknownRegion = errors.New("client: unknown region")

	// ErrUnknownProgram means that the supplied program code does not refer to a
	// currently available Blizzard program.
	ErrUnknownProgram = errors.New("client: unknown program")

	// ErrNoFilenameMapper means that the Client has no FilenameMapper assigned to it.
	// FilenameMappers are program specific and must be added after calling client.New().
	ErrNoFilenameMapper = errors.New("client: no filename mapper registered")

	// ErrNotExists means that the requested file does not exist.
	ErrNotExists = errors.New("client: no such file")
)

Functions

This section is empty.

Types

type ArchiveEntry

type ArchiveEntry struct {
	Archive ngdp.CDNHash
	Size    uint32
	Offset  uint32
}

An ArchiveEntry contains the location of a given file within the archive set.

type ArchiveMapper

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

An ArchiveMapper maps file CDN hashes to their location within the set of archives.

func (*ArchiveMapper) Map

func (e *ArchiveMapper) Map(in ngdp.CDNHash) (entry ArchiveEntry, ok bool)

Map takes a CDNHash of a desired file and returns the CDNHash of the containing archive, as well as the size and offset within the archive.

If the file does not exist in any known archives, then ok will be false.

type Client

type Client struct {
	LowLevelClient *LowLevelClient

	CDNInfo     *ngdp.CDNInfo
	VersionInfo *ngdp.VersionInfo

	BuildConfig *ngdp.BuildConfig
	CDNConfig   *ngdp.CDNConfig

	ArchiveMapper  *ArchiveMapper
	EncodingMapper *encoding.Mapper
	FilenameMapper ngdp.FilenameMapper
}

A Client provides a nice interface to interacting with NGDP, to make retrieving individual files easy.

func New

func New(ctx context.Context, program ngdp.ProgramCode, region ngdp.Region) (*Client, error)

New creates a new Client for the given ProgramCode and Region.

It will automatically create an ArchiveMapper and Encoder as appropriate.

func (*Client) Fetch

func (c *Client) Fetch(ctx context.Context, h ngdp.ContentHash) (*Response, error)

Fetch retrieves a given file by the hash of its contents. After all, CASC is content-addressable storage.

func (*Client) FetchFilename

func (c *Client) FetchFilename(ctx context.Context, fn string) (*Response, error)

FetchFilename retrieves a given file by its filename.

FetchFilename requires that a FilenameMapper has been registered. For Heroes of the Storm, mndx.Decorate can be used to register an appropriate mapper.

type LowLevelClient

type LowLevelClient struct {
	Client *http.Client
}

A LowLevelClient provides simple wrappers to make basic NGDP operations easier.

func (*LowLevelClient) ArchiveMapper

func (c *LowLevelClient) ArchiveMapper(ctx context.Context, cdn ngdp.CDNInfo, archives []ngdp.CDNHash) (*ArchiveMapper, error)

func (*LowLevelClient) BuildConfig

func (c *LowLevelClient) BuildConfig(ctx context.Context, cdn ngdp.CDNInfo, version ngdp.VersionInfo) (ngdp.BuildConfig, error)

func (*LowLevelClient) CDN

func (c *LowLevelClient) CDN(ctx context.Context, program ngdp.ProgramCode, region ngdp.Region) (ngdp.CDNInfo, error)

func (*LowLevelClient) CDNConfig

func (c *LowLevelClient) CDNConfig(ctx context.Context, cdn ngdp.CDNInfo, version ngdp.VersionInfo) (ngdp.CDNConfig, error)

func (*LowLevelClient) Configs

func (*LowLevelClient) EncodingTable

func (c *LowLevelClient) EncodingTable(ctx context.Context, cdn ngdp.CDNInfo, encodingHash ngdp.CDNHash) (*encoding.Mapper, error)

func (*LowLevelClient) Fetch

func (c *LowLevelClient) Fetch(ctx context.Context, cdnInfo ngdp.CDNInfo, cdnHash ngdp.CDNHash) (io.ReadCloser, error)

Fetch retrieves a piece of data content by its CDNHash.

func (*LowLevelClient) Info

func (*LowLevelClient) Mappers

func (c *LowLevelClient) Mappers(ctx context.Context, cdn ngdp.CDNInfo, cdnConfig ngdp.CDNConfig, buildConfig ngdp.BuildConfig) (*encoding.Mapper, *ArchiveMapper, error)

func (*LowLevelClient) NewArchiveMapper

func (llc *LowLevelClient) NewArchiveMapper(ctx context.Context, cdnInfo ngdp.CDNInfo, archives []ngdp.CDNHash) (*ArchiveMapper, error)

NewArchiveMapper creates a new archive mapper from the provided set of archives.

func (*LowLevelClient) Version

func (c *LowLevelClient) Version(ctx context.Context, program ngdp.ProgramCode, region ngdp.Region) (ngdp.VersionInfo, error)

type Response

type Response struct {
	// Body is the actual file itself. It must be closed when no longer needed.
	Body io.ReadCloser

	// ContentHash is the file's content hash.
	ContentHash ngdp.ContentHash

	// CDNHash is the *file's* CDN hash.
	CDNHash ngdp.CDNHash

	// RetrievedCDNHash is the CDN hash of the file which was actually retrieved.
	// If the file was inside an archive, then this will be the archive's CDN hash.
	RetrievedCDNHash ngdp.CDNHash
}

A Response is returned from retrieving a file.

Jump to

Keyboard shortcuts

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