extension

package
v0.0.0-...-0dbc52a Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

README

libmqtt Extension

Extensions for libmqtt client

Extension List

  • Persist Extension
    1. RedisPersist (Test) - Use redis as session state persist storage
  • Router Extension
    1. HttpRouter (TODO) - HTTP path router for MQTT message

Usage

  1. Go get extension package
go get github.com/goiiot/libmqtt/extension
  1. Import extensions
import "github.com/goiiot/libmqtt/extension"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpRouter

type HttpRouter struct {
}

HttpRouter is a HTTP URL style router

func (*HttpRouter) Dispatch

func (r *HttpRouter) Dispatch(p *lib.PublishPacket)

Dispatch the received packet

func (*HttpRouter) Handle

func (r *HttpRouter) Handle(topic string, h lib.TopicHandler)

Handle the topic with TopicHandler h

func (*HttpRouter) Name

func (r *HttpRouter) Name() string

Name of HttpRouter is "HttpRouter"

type RedisPersist

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

RedisPersist defines the persist method with redis

func NewRedisPersist

func NewRedisPersist(conn *redis.Client, mainKey string) *RedisPersist

NewRedisPersist will create a new RedisPersist for session persist with provided redis connection and key mainKey, if passed empty mainKey here, the default mainKey "libmqtt" will be used if no redis client (nil) provided, will return nil

func (*RedisPersist) Delete

func (r *RedisPersist) Delete(key string) error

Delete a persisted packet with key

func (*RedisPersist) Destroy

func (r *RedisPersist) Destroy() error

Destroy stored data

func (*RedisPersist) Load

func (r *RedisPersist) Load(key string) (lib.Packet, bool)

Load a packet from stored data according to the key

func (*RedisPersist) Name

func (r *RedisPersist) Name() string

Name of RedisPersist is "RedisPersist"

func (*RedisPersist) Range

func (r *RedisPersist) Range(f func(string, lib.Packet) bool)

Range over data stored, return false to break the range

func (*RedisPersist) Store

func (r *RedisPersist) Store(key string, p lib.Packet) error

Store a packet with key

Jump to

Keyboard shortcuts

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