helpers

package
v0.0.0-...-6c532cc Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EOFTimeout = time.Second * 60

EOFTimeout is the maximum amount of time to wait to successfully observe an EOF on the stream. Defaults to 60 seconds.

View Source
var ErrExpectedEOF = errors.New("read data when expecting EOF")

ErrExpectedEOF is returned when we read data while expecting an EOF.

Functions

func AwaitEOF

func AwaitEOF(s network.Stream) error

AwaitEOF waits for an EOF on the given stream, returning an error if that fails. It waits at most EOFTimeout (defaults to 1 minute) after which it resets the stream.

func FullClose

func FullClose(s network.Stream) error

FullClose closes the stream and waits to read an EOF from the other side.

* If it reads any data *before* the EOF, it resets the stream. * If it doesn't read an EOF within EOFTimeout, it resets the stream.

You'll likely want to invoke this as `go FullClose(stream)` to close the stream in the background.

func MultistreamSemverMatcher

func MultistreamSemverMatcher(base protocol.ID) (func(string) bool, error)

MultistreamSemverMatcher returns a matcher function for a given base protocol. The matcher function will return a boolean indicating whether a protocol ID matches the base protocol. A given protocol ID matches the base protocol if the IDs are the same and if the semantic version of the base protocol is the same or higher than that of the protocol ID provided. TODO

Types

This section is empty.

Jump to

Keyboard shortcuts

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