websocket

package
v0.0.0-...-77132cc Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Options)

Option func

func Cache

func Cache(c cache.Service) Option

Cache to bind cache interface to engine server

func CheckOrigin

func CheckOrigin(f func(r *http.Request) bool) Option

CheckOrigin to set origin checking function

func EnableCompression

func EnableCompression(b bool) Option

EnableCompression to set compression settings for websocket

func GQLSubscription

func GQLSubscription(s gws.Service) Option

GQLSubscription to bind graphql subscription interface to websocket server

func HandshakeTimeout

func HandshakeTimeout(d time.Duration) Option

HandshakeTimeout to set server handshake timeout

func ID

func ID(s string) Option

ID to change server reference id

func Message

func Message(m message.Service) Option

Message broker

func ReadBufferSize

func ReadBufferSize(i int) Option

ReadBufferSize to set server read buffer size

func Router

func Router(r router.Service) Option

Router to bind router to engine server

func Sync

func Sync(s sync.Service) Option

Sync to bind sync interface to websocket server

func WriteBufferSize

func WriteBufferSize(i int) Option

WriteBufferSize to set server write buffer size

type Options

type Options struct {

	// engine server unique id
	ID string

	// HandshakeTimeout specifies the duration for the handshake to complete.
	HandshakeTimeout time.Duration

	// ReadBufferSize and WriteBufferSize specify I/O buffer sizes. If a buffer
	// size is zero, then a default value of 4096 is used. The I/O buffer sizes
	// do not limit the size of the messages that can be sent or received.
	ReadBufferSize, WriteBufferSize int

	// CheckOrigin returns true if the request Origin header is acceptable. If
	// CheckOrigin is nil, the host in the Origin header must not be set or
	// must match the host of the request.
	CheckOrigin func(r *http.Request) bool

	// EnableCompression specify if the server should attempt to negotiate per
	// message compression (RFC 7692). Setting this value to true does not
	// guarantee that compression will be supported. Currently only "no context
	// takeover" modes are supported.
	EnableCompression bool

	// Sync engine server
	Sync sync.Service

	// GraphQL subscription server
	GQLSubscription gws.Service

	// Cache server
	Cache cache.Service

	// Message broker
	Message message.Service

	// Router
	Router router.Service
}

Options is the engine server options

type Service

type Service interface {
	Start() error
	Stop() error
	Handle(router.Context)
	String() string
}

Service interface

func New

func New(opts ...Option) Service

New creates engine server

Jump to

Keyboard shortcuts

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