reconws

package module
v0.0.0-...-34f25fe Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2019 License: AGPL-3.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReconWs

type ReconWs struct {
	ForwardIncoming bool
	In              chan WsMessage
	Out             chan WsMessage
	Retry           RetryConfig
	Stats           *chanstats.ChanStats
	Url             string
}

func New

func New() *ReconWs

func (*ReconWs) Dial

func (r *ReconWs) Dial(ctx context.Context, urlStr string) error

Dial the websocket server once. If dial fails then return immediately If dial succeeds then handle message traffic until the context is cancelled

func (*ReconWs) Reconnect

func (r *ReconWs) Reconnect(ctx context.Context, url string)

run this in a separate goroutine so that the connection can be ended from where it was initialised, by close((* ReconWs).Stop)

type RetryConfig

type RetryConfig struct {
	Factor  float64
	Jitter  bool
	Min     time.Duration
	Max     time.Duration
	Timeout time.Duration
}

type WsMessage

type WsMessage struct {
	Data []byte
	Type int
}

Jump to

Keyboard shortcuts

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