transport

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultHost          = "localhost"
	DefaultPort          = uint16(3333)
	DefaultEncoder       = codec.PlainEncoder
	DefaultDecoder       = codec.PlainDecoder
	DefaultDialTimeout   = policy.ConstantTimeout(time.Second)
	DefaultClientTimeout = 10 * time.Second
	DefaultServerTimeout = 10 * time.Second
	DefaultExpiryTimeout = time.Minute
)

Default options.

Functions

This section is empty.

Types

type Options

type Options struct {
	Logger          *zap.Logger
	Host            string
	Port            uint16
	Encoder         codec.Encoder
	Decoder         codec.Decoder
	DialTimeout     policy.Timeout
	ClientTimeout   time.Duration
	ServerTimeout   time.Duration
	OncePoolOptions handshake.OncePoolOptions
	ExpiryDuration  time.Duration
}

Options used to parameterise the behaviour of a Transport.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns Options with sensible defaults.

func (Options) WithClientTimeout

func (opts Options) WithClientTimeout(timeout time.Duration) Options

func (Options) WithExpiry

func (opts Options) WithExpiry(minimumDuration time.Duration) Options

func (Options) WithHost

func (opts Options) WithHost(host string) Options

func (Options) WithLogger

func (opts Options) WithLogger(logger *zap.Logger) Options

func (Options) WithOncePoolOptions

func (opts Options) WithOncePoolOptions(oncePoolOpts handshake.OncePoolOptions) Options

func (Options) WithPort

func (opts Options) WithPort(port uint16) Options

func (Options) WithServerTimeout

func (opts Options) WithServerTimeout(timeout time.Duration) Options

type Transport

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

func New

func New(opts Options, self id.Signatory, client *channel.Client, h handshake.Handshake, table dht.Table) *Transport

func (*Transport) Host

func (t *Transport) Host() string

func (*Transport) IsConnected

func (t *Transport) IsConnected(remote id.Signatory) bool

func (*Transport) IsLinked

func (t *Transport) IsLinked(remote id.Signatory) bool
func (t *Transport) Link(remote id.Signatory)

func (*Transport) Port

func (t *Transport) Port() uint16

func (*Transport) Receive

func (t *Transport) Receive(ctx context.Context, receiver func(id.Signatory, wire.Packet) error)

func (*Transport) Run

func (t *Transport) Run(ctx context.Context)

func (*Transport) Self

func (t *Transport) Self() id.Signatory

func (*Transport) Send

func (t *Transport) Send(ctx context.Context, remote id.Signatory, msg wire.Msg) error

func (*Transport) Table

func (t *Transport) Table() dht.Table
func (t *Transport) Unlink(remote id.Signatory)

Jump to

Keyboard shortcuts

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