session

package
v0.0.0-...-6789dc4 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: GPL-3.0, GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package session has code handling long-lived connections from devices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Session

func Session(conn net.Conn, brkr broker.Broker, cfg SessionConfig, track SessionTracker) error

Session manages the session with a client.

Types

type SessionConfig

type SessionConfig interface {
	// pings are emitted each ping interval
	PingInterval() time.Duration
	// send and waiting for response shouldn't take more than exchange
	// timeout
	ExchangeTimeout() time.Duration
}

SessionConfig is for carrying the session configuration.

type SessionTracker

type SessionTracker interface {
	logger.Logger
	// Session got started.
	Start(WithRemoteAddr)
	// SessionId
	SessionId() string
	// Session got registered with broker as sess BrokerSession.
	Registered(sess broker.BrokerSession)
	// Report effective elapsed ping interval.
	EffectivePingInterval(time.Duration)
	// Session got ended with error err (can be nil).
	End(error) error
}

SessionTracker logs session events.

func NewTracker

func NewTracker(logger logger.Logger) SessionTracker

type WithRemoteAddr

type WithRemoteAddr interface {
	RemoteAddr() net.Addr
}

WithRemoteAddr can report a remote address.

Jump to

Keyboard shortcuts

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