clientutil

package
v2.0.1-beta.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoOverlap = errors.New("invalid range: failed to overlap")

ErrNoOverlap is returned by ParseRange if first-byte-pos of all of the byte-range-spec values is greater than the content size.

Functions

func GenPeerID

func GenPeerID(peerHost *scheduler.PeerHost) string

func GetContentRange

func GetContentRange(start, end, total int64) string

Example:

"Content-Range": "bytes 100-200/1000"
"Content-Range": "bytes 100-200/*"

Types

type BufferedReader

type BufferedReader struct {
	B *bufio.Reader
	R io.Reader
}

func BufferReader

func BufferReader(buf *bufio.Reader, real io.Reader) *BufferedReader

func (BufferedReader) Read

func (b BufferedReader) Read(p []byte) (n int, err error)

type Duration

type Duration struct {
	time.Duration
}

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(node *yaml.Node) error

type KeepAlive

type KeepAlive interface {
	Keep()
	Alive(alive time.Duration) bool
}

func NewKeepAlive

func NewKeepAlive(name string) KeepAlive

type Range

type Range struct {
	Start, Length int64
}

Range specifies the byte range to be sent to the client.

func MustParseRange

func MustParseRange(s string, size int64) Range

func ParseRange

func ParseRange(s string, size int64) ([]Range, error)

ParseRange parses a Range header string as per RFC 7233. ErrNoOverlap is returned if none of the ranges overlap. Example:

"Range": "bytes=100-200"
"Range": "bytes=-50"
"Range": "bytes=150-"
"Range": "bytes=0-0,-1"

copy from go/1.15.2 net/http/fs.go ParseRange

type RateLimit

type RateLimit struct {
	rate.Limit
}

RateLimit is a wrapper for rate.Limit, support json and yaml unmarshal function yaml example 1:

rate_limit: 2097152 # 2MiB

yaml example 2:

rate_limit: 2MiB

func (*RateLimit) UnmarshalJSON

func (r *RateLimit) UnmarshalJSON(b []byte) error

func (*RateLimit) UnmarshalYAML

func (r *RateLimit) UnmarshalYAML(node *yaml.Node) error

Jump to

Keyboard shortcuts

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