Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arthurkiller/mqtt-go
a pure MQTT protocol implements in go focus on performance
https://github.com/arthurkiller/mqtt-go
go mqtt prototype
Last synced: about 1 month ago
JSON representation
a pure MQTT protocol implements in go focus on performance
- Host: GitHub
- URL: https://github.com/arthurkiller/mqtt-go
- Owner: arthurkiller
- License: epl-2.0
- Created: 2018-03-14T03:09:09.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-25T07:05:35.000Z (almost 5 years ago)
- Last Synced: 2024-06-21T04:47:49.478Z (5 months ago)
- Topics: go, mqtt, prototype
- Language: Go
- Homepage:
- Size: 65.4 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mqtgo [![Build Status](https://travis-ci.org/arthurkiller/mqtgo.svg?branch=master)](https://travis-ci.org/arthurkiller/mqtgo) [![Go Report Card](https://goreportcard.com/badge/github.com/arthurkiller/mqtgo)](https://goreportcard.com/report/github.com/arthurkiller/mqtgo) [![codecov](https://codecov.io/gh/arthurkiller/mqtgo/branch/master/graph/badge.svg)](https://codecov.io/gh/arthurkiller/mqtgo) [![GoDoc](https://godoc.org/github.com/arthurkiller/mqtgo/packets?status.svg)](https://godoc.org/github.com/arthurkiller/mqtgo/packets)
mqtgo is a pure MQTT protocol packets in go focus on performencethis project was based on eclipse.paho mqtt packet
## benchmark
* goos: darwin
* goarch: amd64```
BenchmarkNewControlPacket-4 20000000 85.5 ns/op 0 B/op 0 allocs/op
BenchmarkParallelNewControlPacket-4 10000000 169 ns/op 0 B/op 0 allocs/op
BenchmarkReadPacket-4 500000 2340 ns/op 930 B/op 2 allocs/op
```compare with paho mqtt packets
```
benchmark old ns/op new ns/op delta
BenchmarkNewControlPacket-4 90.9 85.5 -5.94%
BenchmarkParallelNewControlPacket-4 178 169 -5.06%
BenchmarkReadPacket-4 2707 2340 -13.56%benchmark old allocs new allocs delta
BenchmarkNewControlPacket-4 1 0 -100.00%
BenchmarkParallelNewControlPacket-4 1 0 -100.00%
BenchmarkReadPacket-4 8 2 -75.00%benchmark old bytes new bytes delta
BenchmarkNewControlPacket-4 44 0 -100.00%
BenchmarkParallelNewControlPacket-4 44 0 -100.00%
BenchmarkReadPacket-4 2116 930 -56.05%
```## TODO
* try to redesign the protocol``` golang
package mqtttype Unmarshaler interface {
UnmarshalMqtt() error
}
type Marshaler interface {
MarshalMqtt()([]byte, error)
}func Marshal(v ControlPacket) ([]byte, error)
func Unmarshal(data []byte, v ControlPacket) errortype Decoder struct
func NewDecoder(r io.Reader) *Decoder
func (d *Decoder) Decode() ControlPacket, error
func (d *Decoder) DecodeFixedHeader() *FixedHeader, error
func (d *Decoder) DecodeControlPacket() ControlPacket, errortype Encoder struct
func NewEncoder(w io.Writer) *Encoder
func (e *Encoder) Encode(v ControlPacket) error
func (e *Encoder) EncodeFixedHeader(fh *FixedHeader) error
func (e *Eecoder) EncodeControlPacket(cp ControlPacket) error
`````` golang
type XXXPacket struct
func NewXXXPacket() *XXXPacket
func NewXXXPacketWithHeader(fh *FixedHeader) *XXXPacket
func (m XXXPacket) MarshalMqtt() ([]byte, error)
func (m *XXXPacket) UnmarshalMqtt(data []byte) errortype XXXPacketDecoder struct
func NewXXXPacketDecoder(r io.Reader) *XXXPacketDecoder
func (d XXXPacketDecoder)Decode() *NewXXXPacket,error
```