fasthttp

package module
v0.0.0-...-6531eef Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: MIT Imports: 16 Imported by: 0

README

WebWire

A transport layer implementation for webwire-go based on fasthttp/websocket

GoReportCard
GoDoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientTransport

type ClientTransport struct {
	// ServerAddress specifies the server address URL
	ServerAddress url.URL

	// Upgrader specifies the websocket connection upgrader
	Dialer websocket.Dialer
}

ClientTransport implements the webwire client transport layer with fasthttp

func (*ClientTransport) NewSocket

func (cltTrans *ClientTransport) NewSocket(
	dialTimeout time.Duration,
) (webwire.ClientSocket, error)

NewSocket implements the ClientTransport interface

type ErrSockRead

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

ErrSockRead implements the webwire.ErrSockRead interface

func (ErrSockRead) Error

func (err ErrSockRead) Error() string

Error implements the Go error interface

func (ErrSockRead) IsCloseErr

func (err ErrSockRead) IsCloseErr() bool

IsCloseErr implements the ErrSockRead interface

type SockReadWrongMsgTypeErr

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

SockReadWrongMsgTypeErr implements the ErrSockRead interface

func (SockReadWrongMsgTypeErr) Error

func (err SockReadWrongMsgTypeErr) Error() string

Error implements the Go error interface

func (SockReadWrongMsgTypeErr) IsCloseErr

func (err SockReadWrongMsgTypeErr) IsCloseErr() bool

IsCloseErr implements the ErrSockRead interface

type Socket

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

Socket implements the webwire.Socket interface using the fasthttp/websocket library

func NewConnectedSocket

func NewConnectedSocket(conn *websocket.Conn) *Socket

NewConnectedSocket creates a new fasthttp/websocket based socket instance

func (*Socket) Close

func (sock *Socket) Close() error

Close implements the webwire.Socket interface

func (*Socket) Dial

func (sock *Socket) Dial(deadline time.Time) (err error)

Dial implements the webwire.Socket interface

func (*Socket) GetWriter

func (sock *Socket) GetWriter() (io.WriteCloser, error)

GetWriter implements the webwire.Socket interface

func (*Socket) IsConnected

func (sock *Socket) IsConnected() bool

IsConnected implements the webwire.Socket interface

func (*Socket) Read

func (sock *Socket) Read(
	msg *message.Message,
	deadline time.Time,
) webwire.ErrSockRead

Read implements the webwire.Socket interface

func (*Socket) RemoteAddr

func (sock *Socket) RemoteAddr() net.Addr

RemoteAddr implements the webwire.Socket interface

type TLS

type TLS struct {
	CertFilePath       string
	PrivateKeyFilePath string
	Config             *tls.Config
}

TLS represents TLS configuration

type Transport

type Transport struct {
	// Host defines the address of the host
	Host string

	// OnOptions is invoked when the websocket endpoint is examined by the
	// client using the HTTP OPTION method.
	OnOptions func(*fasthttp.RequestCtx)

	// BeforeUpgrade is invoked right before the upgrade of the connection of an
	// incoming HTTP request to a WebSocket connection and can be used to
	// intercept, configure or prevent incoming connections. BeforeUpgrade must
	// return the connection options to be applied or set options.Connection to
	// webwire.Refuse to refuse the incoming connection
	BeforeUpgrade func(ctx *fasthttp.RequestCtx) webwire.ConnectionOptions

	// WarnLog defines the warn logging output target
	WarnLog *log.Logger

	// ErrorLog defines the error logging output target
	ErrorLog *log.Logger

	// KeepAlive enables the keep-alive option if set to a duration above -1.
	// KeepAlive is automatically set to 30 seconds when it's set to 0
	KeepAlive time.Duration

	// Upgrader specifies the websocket connection upgrader
	Upgrader *websocket.FastHTTPUpgrader

	// HTTPServer specifies the FastHTTP server
	HTTPServer *fasthttp.Server

	// TLS enables TLS encryption if specified
	TLS *TLS
	// contains filtered or unexported fields
}

Transport implements the webwire transport layer with fasthttp

func (*Transport) Address

func (srv *Transport) Address() url.URL

Address returns the URL address the server is listening on

func (*Transport) Initialize

func (srv *Transport) Initialize(
	options wwr.ServerOptions,
	isShuttingdown wwr.IsShuttingDown,
	onNewConnection wwr.OnNewConnection,
) error

Initialize implements the Transport interface

func (*Transport) Serve

func (srv *Transport) Serve() error

Serve implements the Transport interface

func (*Transport) Shutdown

func (srv *Transport) Shutdown() error

Shutdown implements the Transport interface

Jump to

Keyboard shortcuts

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