Skip to content

Commit

Permalink
Merge pull request #70 from DrmagicE/federation-dev
Browse files Browse the repository at this point in the history
docs: add federation plugin info in README
  • Loading branch information
DrmagicE authored Feb 16, 2021
2 parents 0179b7a + f06e1ac commit 43210cb
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 30 deletions.
18 changes: 4 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[中文文档](https://github.com/DrmagicE/gmqtt/blob/master/README_ZH.md)
# Gmqtt [![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go) [![Build Status](https://travis-ci.org/DrmagicE/gmqtt.svg?branch=master)](https://travis-ci.org/DrmagicE/gmqtt) [![codecov](https://codecov.io/gh/DrmagicE/gmqtt/branch/master/graph/badge.svg)](https://codecov.io/gh/DrmagicE/gmqtt) [![Go Report Card](https://goreportcard.com/badge/github.com/DrmagicE/gmqtt)](https://goreportcard.com/report/github.com/DrmagicE/gmqtt)

News: MQTT V5 is now supported. But due to those new features in v5, there area lots of breaking changes.
If you have any migration problems, feel free to raise an issue.
Or you can use the latest v3 [broker](https://github.com/DrmagicE/gmqtt/tree/v0.1.4).
News: Cluster mode is now supported, see [federation plugin](./plugin/federation/README.md) for examples and details.

# Installation
```$ go get -u github.com/DrmagicE/gmqtt```
Expand All @@ -18,11 +16,7 @@ See `Server` interface in `server/server.go` and [admin](https://github.com/Drma
* Provide GRPC and REST APIs to interact with server. (plugin:[admin](https://github.com/DrmagicE/gmqtt/blob/master/plugin/admin/README.md))
* Provide session persistence which means the broker can retrieve the session data after restart.
Currently, only redis backend is supported.



# Limitations
* Cluster is not supported.
* Provide clustering, see [federation plugin](./plugin/federation/README.md) for examples and details.


# Get Started
Expand Down Expand Up @@ -113,7 +107,8 @@ Gmqtt implements the following hooks:
| OnDelivered | When a message is delivered to the client | |
| OnClosed | When the client is closed | |
| OnMsgDropped | When a message is dropped for some reasons| |

| OnWillPublish | When the client is going to deliver a will message | Modify or drop the will message |
| OnWillPublished| When a will message has been delivered| |

See `/examples/hook` for details.

Expand All @@ -132,8 +127,3 @@ $ go test -race ./...
## Integration Test
[paho.mqtt.testing](https://github.com/eclipse/paho.mqtt.testing).


# TODO
* Support bridge mode and cluster.

*Breaking changes may occur when adding this new features.*
13 changes: 4 additions & 9 deletions README_ZH.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Gmqtt [![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go) [![Build Status](https://travis-ci.org/DrmagicE/Gmqtt.svg?branch=master)](https://travis-ci.org/DrmagicE/Gmqtt) [![codecov](https://codecov.io/gh/DrmagicE/Gmqtt/branch/master/graph/badge.svg)](https://codecov.io/gh/DrmagicE/Gmqtt) [![Go Report Card](https://goreportcard.com/badge/github.com/DrmagicE/Gmqtt)](https://goreportcard.com/report/github.com/DrmagicE/Gmqtt)

News: 现已支持V5版本,但由于V5的功能特性,Gmqtt做了很多不兼容的改动,对此有疑问欢迎提issue交流,或者依然使用最新的[V3版本](https://github.com/DrmagicE/gmqtt/tree/v0.1.4).
News: 集群模式已支持,示例和详情请参考[federation plugin](./plugin/federation/README.md)

Gmqtt是用Go语言实现的一个具备灵活灵活扩展能力,高性能的MQTT broker,其完整实现了MQTT V3.1.1和V5协议。

Expand All @@ -15,9 +15,7 @@ Gmqtt是用Go语言实现的一个具备灵活灵活扩展能力,高性能的M
* 提供监控指标,支持prometheus。 (plugin: [prometheus](https://github.com/DrmagicE/Gmqtt/blob/master/plugin/prometheus/READEME.md))
* GRPC和REST API 支持. (plugin:[admin](https://github.com/DrmagicE/Gmqtt/blob/master/plugin/admin/READEME.md))
* 支持session持久化,broker重启消息不丢失,目前支持redis持久化。

# 缺陷
* 不支持集群。
* 支持集群, 示例和详情请参考[federation plugin](./plugin/federation/README.md)

# 开始

Expand Down Expand Up @@ -103,6 +101,8 @@ Gmqtt实现了下列钩子方法。
| OnDelivered | 消息从broker投递到客户端后调用 | |
| OnClosed | 客户端断开连接后调用 | 统计在线客户端数量 |
| OnMsgDropped | 消息被丢弃时调用 | |
| OnWillPublish | 发布遗嘱消息前 | 修改或丢弃遗嘱消息|
| OnWillPublished| 发布遗嘱消息后| |

`/examples/hook` 中有常用钩子的使用方法介绍。

Expand All @@ -118,8 +118,3 @@ $ go test -race ./...
## 集成测试
[paho.mqtt.testing](https://github.com/eclipse/paho.mqtt.testing).


# TODO
* 桥接模式,集群模式

*暂时不保证向后兼容,在添加上述新功能时可能会有breaking changes。*
9 changes: 7 additions & 2 deletions cmd/gmqttd/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ mqtt:
shared_subscription_available: true
maximum_qos: 2
retain_available: true
max_queued_messages: 10000
max_inflight: 1000
max_queued_messages: 1000
max_inflight: 100
queue_qos0_messages: true
delivery_mode: onlyonce # overlap or onlyonce
allow_zero_length_clientid: true
Expand Down Expand Up @@ -98,6 +98,11 @@ plugins:
advertise_fed_addr: :8901
# gossip_addr is the address that the gossip will listen on, It is used for both UDP and TCP gossip. Defaults to :8902
gossip_addr: :8902
# advertise_gossip_addr is used to change the gossip server address that we advertise to other nodes in the cluster.
# Defaults to "GossipAddr" or the private IP address of the node if the IP in "GossipAddr" is 0.0.0.0.
# If the port is missing, the default gossip port (8902) will be used.
advertise_gossip_addr: :8902

# retry_join is the address of other nodes to join upon starting up.
# If port is missing, the default gossip port (8902) will be used.
#retry_join:
Expand Down
2 changes: 1 addition & 1 deletion mock_gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mockgen -source=config/config.go -destination=./config/config_mock.go -package=c
mockgen -source=persistence/queue/elem.go -destination=./persistence/queue/elem_mock.go -package=queue -self_package=github.com/DrmagicE/gmqtt/queue
mockgen -source=persistence/queue/queue.go -destination=./persistence/queue/queue_mock.go -package=queue -self_package=github.com/DrmagicE/gmqtt/queue
mockgen -source=persistence/session/session.go -destination=./persistence/session/session_mock.go -package=session -self_package=github.com/DrmagicE/gmqtt/session
mockgen -source=persistence/subscription/interface.go -destination=./persistence/subscription/interface_mock.go -package=subscription -self_package=github.com/DrmagicE/gmqtt/subscription
mockgen -source=persistence/subscription/subscription.go -destination=./persistence/subscription/subscription_mock.go -package=subscription -self_package=github.com/DrmagicE/gmqtt/subscription
mockgen -source=persistence/unack/unack.go -destination=./persistence/unack/unack_mock.go -package=unack -self_package=github.com/DrmagicE/gmqtt/unack
mockgen -source=pkg/packets/packets.go -destination=./pkg/packets/packets_mock.go -package=packets -self_package=github.com/DrmagicE/gmqtt/packets
mockgen -source=plugin/auth/account_grpc.pb.go -destination=./plugin/auth/account_grpc.pb_mock.go -package=auth -self_package=github.com/DrmagicE/gmqtt/auth
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugin/federation/examples/join_node3_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ api:
- address: "tcp://127.0.0.1:8284"
http:
- address: "tcp://127.0.0.1:8283"
map: "tcp://127.0.0.1:8284" # The backend gRPC server endpoint,
map: "tcp://127.0.0.1:8284" # The backend gRPC server endpoint
mqtt:
session_expiry: 2h
session_expiry_check_timer: 20s
Expand Down
3 changes: 2 additions & 1 deletion plugin/federation/examples/node1_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ api:
- address: "tcp://127.0.0.1:8084"
http:
- address: "tcp://127.0.0.1:8083"
map: "tcp://127.0.0.1:8084" # The backend gRPC server endpoint,
map: "tcp://127.0.0.1:8084" # The backend gRPC server endpoint
mqtt:
session_expiry: 2h
session_expiry_check_timer: 20s
Expand Down Expand Up @@ -40,6 +40,7 @@ plugins:
# retry_join is the address of other nodes to join upon starting up.
# If port is missing, the default gossip port (8902) will be used.
retry_join:
# Change 127.0.0.1 to real routable ip address if you run gmqtt in multiple nodes.
- 127.0.0.1:8912
# rejoin_after_leave will be pass to "RejoinAfterLeave" in serf configuration.
# It controls our interaction with the snapshot file.
Expand Down
3 changes: 2 additions & 1 deletion plugin/federation/examples/node2_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ api:
- address: "tcp://127.0.0.1:8184"
http:
- address: "tcp://127.0.0.1:8183"
map: "tcp://127.0.0.1:8184" # The backend gRPC server endpoint,
map: "tcp://127.0.0.1:8184" # The backend gRPC server endpoint
mqtt:
session_expiry: 2h
session_expiry_check_timer: 20s
Expand Down Expand Up @@ -40,6 +40,7 @@ plugins:
# retry_join is the address of other nodes to join upon starting up.
# If port is missing, the default gossip port (8902) will be used.
retry_join:
# Change 127.0.0.1 to real routable ip address if you run gmqtt in multiple nodes.
- 127.0.0.1:8902
# rejoin_after_leave will be pass to "RejoinAfterLeave" in serf configuration.
# It controls our interaction with the snapshot file.
Expand Down

0 comments on commit 43210cb

Please sign in to comment.