RMTT

package module
v0.0.4-beta Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

README

Remote Message Telemetry Transport(RMTT) Go Client

This repository provides an implementation of the RMTT (Remote Message Telemetry Transport) protocol in Go.

Overview

The RMTT Go client implementation, primarily inspired by the popular MQTT Go client, paho.mqtt.golang. It offers a similar API structure and design, making it familiar and easy to use for developers experienced with MQTT.

Installation

To install the RMTT Go client, you can use go get:

go get -u github.com/czqu/rmtt-go

Documentation

Index

Constants

View Source
const (
	NET string = "[net]     "
	CLI string = "[client]     "
)

Variables

View Source
var (
	RefusedNotAuthorisedErr = errors.New("The server has rejected our request. Please check your permissions")
	ProtocolViolationErr    = errors.New("The server has rejected our request. Please check your permissions")
)
View Source
var ErrNotConnected = errors.New("not Connected")
View Source
var TimedOut = errors.New("context canceled")

Functions

func WaitTokenTimeout

func WaitTokenTimeout(t Token, d time.Duration) error

Types

type Client

type Client interface {
	IsConnected() bool

	Connect() Token
	Push(payload interface{}) Token
	Disconnect(quiesce uint)
	AddPayloadHandlerLast(handler MessageHandler)
}

func NewClient

func NewClient(o *ClientOptions) Client

type ClientOptions

type ClientOptions struct {
	Servers              []*url.URL
	Token                string
	Heartbeat            int64
	ProtocolVersion      uint
	ConnectRetry         bool
	ConnectRetryInterval time.Duration
	ConnectTimeout       time.Duration
	WriteTimeout         time.Duration
	AutoReconnect        bool
	OnConnectionLost     ConnectionLostHandler
	MaxReconnectInterval time.Duration
	OnReconnecting       ReconnectHandler
	TLSConfig            *tls.Config
	OnConnectAttempt     ConnectionAttemptHandler
}

func NewClientOptions

func NewClientOptions() *ClientOptions

func (*ClientOptions) AddServer

func (o *ClientOptions) AddServer(server string) *ClientOptions

func (*ClientOptions) SetConnectTimeout

func (o *ClientOptions) SetConnectTimeout(k time.Duration) *ClientOptions

func (*ClientOptions) SetConnectionAttemptHandler

func (o *ClientOptions) SetConnectionAttemptHandler(onConnectAttempt ConnectionAttemptHandler) *ClientOptions

func (*ClientOptions) SetHeartbeat

func (o *ClientOptions) SetHeartbeat(k time.Duration) *ClientOptions

func (*ClientOptions) SetTlsConfig

func (o *ClientOptions) SetTlsConfig(config *tls.Config) *ClientOptions

func (*ClientOptions) SetToken

func (o *ClientOptions) SetToken(id string) *ClientOptions

func (*ClientOptions) SetWriteTimeout

func (o *ClientOptions) SetWriteTimeout(k time.Duration) *ClientOptions

type ConnectToken

type ConnectToken struct {
	// contains filtered or unexported fields
}

func (*ConnectToken) Done

func (b *ConnectToken) Done() <-chan struct{}

Done implements the Token Done method.

func (*ConnectToken) Error

func (b *ConnectToken) Error() error

func (*ConnectToken) HandlerError

func (b *ConnectToken) HandlerError(e error)

func (*ConnectToken) ReturnCode

func (c *ConnectToken) ReturnCode() byte

func (*ConnectToken) SetErrorHandler

func (b *ConnectToken) SetErrorHandler(f func(error))

func (*ConnectToken) Wait

func (b *ConnectToken) Wait() bool

func (*ConnectToken) WaitTimeout

func (b *ConnectToken) WaitTimeout(d time.Duration) bool

type ConnectionAttemptHandler

type ConnectionAttemptHandler func(server *url.URL, tlsCfg *tls.Config) *tls.Config

type ConnectionLostHandler

type ConnectionLostHandler func(Client, error)

type DisconnectToken

type DisconnectToken struct {
	// contains filtered or unexported fields
}

func (*DisconnectToken) Done

func (b *DisconnectToken) Done() <-chan struct{}

Done implements the Token Done method.

func (*DisconnectToken) Error

func (b *DisconnectToken) Error() error

func (*DisconnectToken) HandlerError

func (b *DisconnectToken) HandlerError(e error)

func (*DisconnectToken) SetErrorHandler

func (b *DisconnectToken) SetErrorHandler(f func(error))

func (*DisconnectToken) Wait

func (b *DisconnectToken) Wait() bool

func (*DisconnectToken) WaitTimeout

func (b *DisconnectToken) WaitTimeout(d time.Duration) bool

type Logger

type Logger interface {
	Println(v ...interface{})
	Printf(format string, v ...interface{})
}
var (
	ERROR Logger = NOOPLogger{}
	INFO  Logger = NOOPLogger{}
	WARN  Logger = NOOPLogger{}
	DEBUG Logger = NOOPLogger{}
)

type Message

type Message interface {
	Payload() []byte
}

type MessageHandler

type MessageHandler func(Client, Message)

type NOOPLogger

type NOOPLogger struct{}

func (NOOPLogger) Printf

func (NOOPLogger) Printf(format string, v ...interface{})

func (NOOPLogger) Println

func (NOOPLogger) Println(v ...interface{})

type PacketAndToken

type PacketAndToken struct {
	// contains filtered or unexported fields
}

type PushToken

type PushToken struct {
	// contains filtered or unexported fields
}

func (*PushToken) Done

func (b *PushToken) Done() <-chan struct{}

Done implements the Token Done method.

func (*PushToken) Error

func (b *PushToken) Error() error

func (*PushToken) HandlerError

func (b *PushToken) HandlerError(e error)

func (*PushToken) SetErrorHandler

func (b *PushToken) SetErrorHandler(f func(error))

func (*PushToken) Wait

func (b *PushToken) Wait() bool

func (*PushToken) WaitTimeout

func (b *PushToken) WaitTimeout(d time.Duration) bool

type ReconnectHandler

type ReconnectHandler func(Client, *ClientOptions)

type Token

type Token interface {
	Wait() bool

	WaitTimeout(time.Duration) bool

	Done() <-chan struct{}

	Error() error
	SetErrorHandler(func(error))
}

type TokenErrorSetter

type TokenErrorSetter interface {
	// contains filtered or unexported methods
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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