carrier

package module
v0.0.0-...-ea4014d Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 16 Imported by: 0

README

carrier

Documentation

Index

Constants

View Source
const (
	// WEBSOCKET services
	WEBSOCKET = iota
	// MQTT services
	MQTT
	// MAIL services
	MAIL
)
View Source
const (
	// CUSTOMMAIL services
	CUSTOMMAIL = iota
)
View Source
const (
	// ECLIPSE services
	ECLIPSE = iota
)
View Source
const (
	// GORILLA services
	GORILLA = iota
)

Variables

View Source
var (
	// EclipseClientSessionMapping singleton pattern
	EclipseClientSessionMapping = make(map[string]*EclipseClient)
)

Functions

func New

func New(carrierType int) func(carrierCompany int, config *Config) interface{}

New carrier based on types

func NewMQTT

func NewMQTT(carrierCompany int, config *Config) interface{}

NewMQTT Factory Pattern

func NewMail

func NewMail(carrierCompany int, config *Config) interface{}

NewMail Factory Pattern

func NewWebsocket

func NewWebsocket(carrierCompany int, config *Config) interface{}

NewWebsocket Factory Pattern

Types

type Config

type Config struct {
	Gorilla    GorillaConfigModel    `json:"gorilla,omitempty"`
	Eclipse    EclipseConfigModel    `json:"eclipse,omitempty"`
	CustomMail CustomMailConfigModel `json:"customMail,omitempty"`
}

Config model for carrier services

type CustomMailClient

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

CustomMailClient manage all Gomail client actions

func (*CustomMailClient) Send

func (cc *CustomMailClient) Send(subject, body string, recipients ...string) error

Send message to recipient

type CustomMailConfigModel

type CustomMailConfigModel struct {
	PoolSize int    `json:"poolSize"`
	Host     string `json:"host"`
	Port     string `json:"port"`
	Identity string `json:"identity"`
	Username string `json:"username"`
	Password string `json:"password"`
}

CustomMailConfigModel connection config model

type EclipseClient

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

EclipseClient manage all MQTT client actions

func (*EclipseClient) End

func (ec *EclipseClient) End()

End this communication

func (*EclipseClient) IsConnected

func (ec *EclipseClient) IsConnected() bool

IsConnected return connection state

func (*EclipseClient) Publish

func (ec *EclipseClient) Publish(topic, message string) error

Publish message to channel

func (*EclipseClient) Subscribe

func (ec *EclipseClient) Subscribe(topic string, messageHandler mqtt.MessageHandler) error

Subscribe message from channel

type EclipseConfigModel

type EclipseConfigModel struct {
	ClientID string `json:"clientID"`
	URL      string `json:"url"`
	Username string `json:"username"`
	Password string `json:"password"`
}

EclipseConfigModel connection config model

type GorillaClient

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

GorillaClient manage all websocket client actions

func (*GorillaClient) End

func (gc *GorillaClient) End() error

End this communication

func (*GorillaClient) Read

func (gc *GorillaClient) Read() (interface{}, error)

Read message from channel

func (*GorillaClient) Write

func (gc *GorillaClient) Write(message string) error

Write message to channel

type GorillaConfigModel

type GorillaConfigModel struct {
	Scheme            string        `json:"scheme"`
	URL               string        `json:"url"`
	Channel           string        `json:"channel"`
	RecIntervalMin    time.Duration `json:"recIntervalMin"`    // RecIntervalMin specifies the initial reconnecting interval, example: 2 * time.Second (2 seconds)
	RecIntervalMax    time.Duration `json:"recIntervalMax"`    // RecIntervalMax specifies the maximum reconnecting interval, example: 30 * time.Second (30 seconds)
	RecIntervalFactor float64       `json:"recIntervalFactor"` // RecIntervalFactor specifies the rate of increase of the reconnection interval, example: 0.5 * time.Second (0.5 seconds)
}

GorillaConfigModel connection config model

type IMQTT

type IMQTT interface {
	Publish(topic, message string) error
	Subscribe(topic string, messageHandler mqtt.MessageHandler) error
	IsConnected() bool
	End()
}

IMQTT factory pattern interface

func NewEclipseClient

func NewEclipseClient(config *EclipseConfigModel) IMQTT

NewEclipseClient init new instance

type IMail

type IMail interface {
	Send(subject, body string, recipients ...string) error
}

IMail factory pattern interface

func NewCustomMailClient

func NewCustomMailClient(config *CustomMailConfigModel) IMail

NewCustomMailClient init new instance

type IWebsocket

type IWebsocket interface {
	Write(message string) error
	Read() (interface{}, error)
	End() error
}

IWebsocket factory pattern interface

func NewGorillaClient

func NewGorillaClient(config *GorillaConfigModel) IWebsocket

NewGorillaClient init new instance

Jump to

Keyboard shortcuts

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