cfg

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultWebsocketWriteTimeout 0, no timeout
	DefaultWebsocketWriteTimeout = 0
	// DefaultWebsocketReadTimeout 0, no timeout
	DefaultWebsocketReadTimeout = 0
	// DefaultWebsocketPongTimeout 60 * time.Second
	DefaultWebsocketPongTimeout = 60 * time.Second
	// DefaultWebsocketPingPeriod (DefaultPongTimeout * 9) / 10
	DefaultWebsocketPingPeriod = (DefaultWebsocketPongTimeout * 9) / 10
	// DefaultWebsocketMaxMessageSize 1024
	DefaultWebsocketMaxMessageSize = 1024
	// DefaultWebsocketReadBufferSize 1MB
	DefaultWebsocketReadBufferSize = 1024 * 1024
	// DefaultWebsocketWriterBufferSize 4096
	DefaultWebsocketWriterBufferSize = 4096
)

Variables

This section is empty.

Functions

func DefaultIDGenerator

func DefaultIDGenerator(c core.Connection) string

DefaultIDGenerator returns a random unique for a new conn. Used when cfg.IDGenerator is nil.

Types

type Config

type Config struct {
	// the server id
	ID string
	// IDGenerator used to create (and later on, set)
	// an ID for each incoming websocket connections (clients).
	// The request is an input parameter which you can use to generate the ID (from headers for example).
	// If empty then the ID is generated by DefaultIDGenerator: randomString(64)
	IDGenerator func(c core.Connection) string
	// record the address of another node
	ClusterMasters []string
	EnableCluster  bool
	// 本节点级别: 0 为非cluster node节点,无法接收链接;  1 为最高级节点
	ClusterLevel uint
	// 连接策略
	// 0: 多(本级) -> 1(本级) -> 1 (高级) 即在本级节点选举出一个当做代表
	// 1: 多(本级)  -> 1(高级)
	ClusterMode uint
	// 是否开启自动检测目标地址
	EnableAutoDetect bool
	// 监听端口访问,只监听1个,失败会port+1再次尝试, 自动检测也是在该范围内检测节点
	ClusterPortMin uint
	ClusterPortMax uint
	// 是否对连接目标地址添加或替换后缀
	ClusterSuffix string
	//
	// CheckOrigin a function that is called right before the handshake,
	// if returns false then that client is not allowed to connect with the websocket server.
	CheckOrigin func(r *http.Request) bool
	// WriteTimeout time allowed to write a message to the conn.
	// 0 means no timeout.
	// Default value is 0
	WriteTimeout time.Duration

	// 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.
	//
	// Defaults to false and it should be remain as it is, unless special requirements.
	EnableCompression bool
	// contains filtered or unexported fields
}

Config the websocket server configuration all of these are optional.

func (*Config) Ctx

func (c *Config) Ctx() context.Context

func (*Config) PingPeriod

func (c *Config) PingPeriod() time.Duration

func (*Config) ReadBufferSize

func (c *Config) ReadBufferSize() int64

func (*Config) ReadTimeout

func (c *Config) ReadTimeout() time.Duration

func (*Config) SetWebds

func (c *Config) SetWebds(w core.Webds)

func (*Config) Validate

func (c *Config) Validate()

Validate validates the configuration

func (*Config) Webds

func (c *Config) Webds() core.Webds

Jump to

Keyboard shortcuts

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