config

package
v0.0.0-...-1059341 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ListenAddr string
	Address    string
	Token      string
	Timeout    time.Duration
	Mode       TraversalMode
	RangeSize  int64
	Verbose    bool
}

Config is a set of titan SDK options.

func DefaultOption

func DefaultOption() Config

DefaultOption returns a default set of options.

type Option

type Option func(opts *Config)

Option is a single titan sdk Config.

func AddressOption

func AddressOption(address string) Option

AddressOption set titan server address

func ListenAddressOption

func ListenAddressOption(addr string) Option

ListenAddressOption set the listen address for titan client, default is :8863

func RangeSizeOption

func RangeSizeOption(size int64) Option

RangeSizeOption specifies the maximum size of each file range that can be downloaded in a single HTTP request. Each range of data is read into memory and then written to the output stream, so the amount of memory used is directly proportional to the size of rangeSize.

Specifically, the estimated amount of memory used can be calculated as maxConcurrent x rangeSize. Keep an eye on memory usage when modifying this value, as setting it too high can result in excessive memory usage and potential out-of-memory errors.

This option only works when using `TraversalModeRange` to download files.

func TimeoutOption

func TimeoutOption(timeout time.Duration) Option

TimeoutOption specifies a time limit for requests made by the http Client.

func TokenOption

func TokenOption(token string) Option

TokenOption set titan server access token

func TraversalModeOption

func TraversalModeOption(mode TraversalMode) Option

TraversalModeOption set the download file traversal algorithm, default using DFS pre-order walk algorithm for dag.

func VerboseOption

func VerboseOption(verbose bool) Option

VerboseOption Make the operation more talkative

type TraversalMode

type TraversalMode int
const (
	// TraversalModeDFS only supports retrieving CAR files and auto decodes them into the raw file format.
	TraversalModeDFS TraversalMode = iota + 1
	// TraversalModeRange allows you to retrieve files of any type, but it does not decode, the files will be retrieved in their original format.
	// It's important to note that when using `TraversalModeRange` to retrieve a CAR file, the entire file must be downloaded before it can be decoded.
	TraversalModeRange
)

Jump to

Keyboard shortcuts

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