service

package
v2.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, config Config, router *mux.Router, fileWatcher *fsnotify.Watcher, logger log.Logger, opt ...func(*Options)) (*service.Service, error)

New creates server.

func TLSConfigToDTLSConfig

func TLSConfigToDTLSConfig(tlsConfig *tls.Config) *dtls.Config

func WithMessagePool

func WithMessagePool(p *pool.Pool) func(*Options)

func WithOnInactivityConnection

func WithOnInactivityConnection(f func(conn mux.Conn)) func(*Options)

func WithOnNewConnection

func WithOnNewConnection(f func(conn mux.Conn)) func(*Options)

func WithOverrideTLS

func WithOverrideTLS(f func(cfg *tls.Config) *tls.Config) func(*Options)

func WithTCPGoPool

func WithTCPGoPool(f coapOptionsConfig.GoPoolFunc[*coapTcpClient.Conn]) func(*Options)

Setup go pool for TCP/TCP-TLS connections

func WithUDPGoPool

func WithUDPGoPool(f coapOptionsConfig.GoPoolFunc[*coapUdpClient.Conn]) func(*Options)

Setup go pool for UDP/DTLS connections

Types

type BlockwiseTransferConfig

type BlockwiseTransferConfig struct {
	Enabled bool   `yaml:"enabled" json:"enabled"`
	SZX     string `yaml:"blockSize" json:"blockSize"`
}

func (*BlockwiseTransferConfig) Validate

func (c *BlockwiseTransferConfig) Validate() error

type Config

type Config struct {
	Addr              string                  `yaml:"address" json:"address"`
	Protocols         []Protocol              `yaml:"protocols" json:"protocols"`
	MaxMessageSize    uint32                  `yaml:"maxMessageSize" json:"maxMessageSize"`
	MessagePoolSize   int                     `yaml:"messagePoolSize" json:"messagePoolSize"`
	BlockwiseTransfer BlockwiseTransferConfig `yaml:"blockwiseTransfer" json:"blockwiseTransfer"`
	TLS               TLSConfig               `yaml:"tls" json:"tls"`
	InactivityMonitor *InactivityMonitor      `yaml:"inactivityMonitor,omitempty" json:"inactivityMonitor,omitempty"`
	KeepAlive         *KeepAlive              `yaml:"keepAlive,omitempty" json:"keepAlive,omitempty"`
}

Config represents configuration of coap service

func (*Config) GetTimeout

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

func (Config) String

func (c Config) String() string

String return string representation of Config

func (*Config) Validate

func (c *Config) Validate() error

type InactivityMonitor

type InactivityMonitor struct {
	Timeout time.Duration `yaml:"timeout" json:"timeout"`
}

func (*InactivityMonitor) Validate

func (c *InactivityMonitor) Validate() error

type KeepAlive

type KeepAlive struct {
	Timeout time.Duration `yaml:"timeout" json:"timeout"`
}

func (*KeepAlive) Validate

func (c *KeepAlive) Validate() error

type Options

type Options struct {
	OverrideTLSConfig      func(cfg *tls.Config) *tls.Config
	OnNewConnection        func(conn mux.Conn)
	OnInactivityConnection func(conn mux.Conn)
	TCPGoPool              coapOptionsConfig.GoPoolFunc[*coapTcpClient.Conn]
	UDPGoPool              coapOptionsConfig.GoPoolFunc[*coapUdpClient.Conn]
	MessagePool            *pool.Pool
}

type Protocol

type Protocol string
const (
	TCP Protocol = "tcp"
	UDP Protocol = "udp"
)

type TLSConfig

type TLSConfig struct {
	Enabled                        *bool                    `yaml:"enabled,omitempty" json:"enabled,omitempty"`
	DisconnectOnExpiredCertificate bool                     `yaml:"disconnectOnExpiredCertificate" json:"disconnectOnExpiredCertificate"`
	Embedded                       certManagerServer.Config `yaml:",inline" json:",inline"`
}

func (TLSConfig) IsEnabled

func (c TLSConfig) IsEnabled() bool

IsEnabled returns true if TLS is not set or it is enabled

func (*TLSConfig) Validate

func (c *TLSConfig) Validate() error

Jump to

Keyboard shortcuts

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