run

package
v0.0.0-...-dfa80c7 Latest Latest
Warning

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

Go to latest
Published: May 7, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDeliveryRetryInterval = 20
	DefaultQueueQos0Messages     = true
	DefaultMaxInflightMessages   = 20
	DefaultLogging               = false
	DefaultMaxMsgQueueMessages   = 2048
)

Default configration

View Source
const ProtocolMQTT = "mqtt"

ProtocolMQTT represents the MQTT protocol under TCP server

View Source
const ProtocolWebsocket = "websocket"

ProtocolWebsocket represents the MQTT protocol under websocket server.

Variables

This section is empty.

Functions

func NewServer

func NewServer(config *Config) (*gmqtt.Server, error)

NewServer creates a new gmqtt.Server instance by the given Config param.

Types

type Command

type Command struct {
	Server *gmqtt.Server
}

Command represents the command executed by `go run main.go`

func NewCommand

func NewCommand() *Command

NewCommand returns Command

func (*Command) Close

func (cmd *Command) Close() error

Close shuts down the server.

func (*Command) ParseConfig

func (cmd *Command) ParseConfig(path string) (*Config, error)

ParseConfig parses the config at path. It returns a demo configuration if path is blank.

func (*Command) ParseFlags

func (cmd *Command) ParseFlags(args ...string) (Options, error)

ParseFlags parses the args into Options.

func (*Command) Run

func (cmd *Command) Run(args ...string) error

Run parses the command arguments and starts the server.

type Config

type Config struct {
	DeliveryRetryInterval int64            `yaml:"delivery_retry_interval"`
	QueueQos0Messages     bool             `yaml:"queue_qos0_messages"`
	MaxInflightMessages   int              `yaml:"max_inflight_messages"`
	MaxMsgQueueMessages   int              `yaml:"max_msgqueue_messages"`
	ProfileConfig         ProfileConfig    `yaml:"profile"`
	Listener              []ListenerConfig `yaml:"listener,flow"`
	Logging               bool             `yaml:"logging"`
	HttpServerConfig      HttpServerConfig `yaml:"http_server"`
}

Config represents the configuration options.

func NewConfig

func NewConfig() *Config

NewConfig returns the default Config instance.

func (*Config) FromConfigFile

func (c *Config) FromConfigFile(fpath string) error

FromConfigFile loads the configuration from a yaml file

func (*Config) Validate

func (c *Config) Validate() error

Validate validate the Config, returns error if it is invalid.

type HttpServerConfig

type HttpServerConfig struct {
	Addr string       `yaml:"addr"`
	User gin.Accounts `yaml:"user"`
}

HttpServerConfig represents the REST server configuration.

type ListenerConfig

type ListenerConfig struct {
	Protocol string `yaml:"protocol"`
	Addr     string `yaml:"addr"`
	CertFile string `yaml:"certfile"`
	KeyFile  string `yaml:"keyfile"`
}

ListenerConfig represents the tcp server configuration.

type Options

type Options struct {
	ConfigPath string
}

Options contains the path of configuration file

type ProfileConfig

type ProfileConfig struct {
	CPUProfile string `yaml:"cpu"`
	MemProfile string `yaml:"mem"`
}

ProfileConfig represents the server profile configuration.

Jump to

Keyboard shortcuts

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