From f06e1ac9dd19344aec7267e4bd62c3b72fa41d88 Mon Sep 17 00:00:00 2001 From: DrmagicE Date: Tue, 16 Feb 2021 18:03:23 +0800 Subject: [PATCH] docs: add federation plugin info in README --- README.md | 18 ++++-------------- README_ZH.md | 13 ++++--------- cmd/gmqttd/default_config.yml | 9 +++++++-- mock_gen.sh | 2 +- ...{interface_mock.go => subscription_mock.go} | 2 +- .../federation/examples/join_node3_config.yml | 2 +- plugin/federation/examples/node1_config.yml | 3 ++- plugin/federation/examples/node2_config.yml | 3 ++- 8 files changed, 22 insertions(+), 30 deletions(-) rename persistence/subscription/{interface_mock.go => subscription_mock.go} (99%) diff --git a/README.md b/README.md index e77541aa..f84610cd 100644 --- a/README.md +++ b/README.md @@ -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``` @@ -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 @@ -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. @@ -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.* diff --git a/README_ZH.md b/README_ZH.md index 78ff5b6f..212ad058 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -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协议。 @@ -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)。 # 开始 @@ -103,6 +101,8 @@ Gmqtt实现了下列钩子方法。 | OnDelivered | 消息从broker投递到客户端后调用 | | | OnClosed | 客户端断开连接后调用 | 统计在线客户端数量 | | OnMsgDropped | 消息被丢弃时调用 | | +| OnWillPublish | 发布遗嘱消息前 | 修改或丢弃遗嘱消息| +| OnWillPublished| 发布遗嘱消息后| | 在 `/examples/hook` 中有常用钩子的使用方法介绍。 @@ -118,8 +118,3 @@ $ go test -race ./... ## 集成测试 [paho.mqtt.testing](https://github.com/eclipse/paho.mqtt.testing). - -# TODO -* 桥接模式,集群模式 - -*暂时不保证向后兼容,在添加上述新功能时可能会有breaking changes。* diff --git a/cmd/gmqttd/default_config.yml b/cmd/gmqttd/default_config.yml index 82c742f4..4f2433d7 100644 --- a/cmd/gmqttd/default_config.yml +++ b/cmd/gmqttd/default_config.yml @@ -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 @@ -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: diff --git a/mock_gen.sh b/mock_gen.sh index e5b6d13b..21b756ba 100755 --- a/mock_gen.sh +++ b/mock_gen.sh @@ -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 diff --git a/persistence/subscription/interface_mock.go b/persistence/subscription/subscription_mock.go similarity index 99% rename from persistence/subscription/interface_mock.go rename to persistence/subscription/subscription_mock.go index 85aa0a58..14d3b2fc 100644 --- a/persistence/subscription/interface_mock.go +++ b/persistence/subscription/subscription_mock.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: persistence/subscription/interface.go +// Source: persistence/subscription/subscription.go // Package subscription is a generated GoMock package. package subscription diff --git a/plugin/federation/examples/join_node3_config.yml b/plugin/federation/examples/join_node3_config.yml index 9cd94f63..f310038e 100644 --- a/plugin/federation/examples/join_node3_config.yml +++ b/plugin/federation/examples/join_node3_config.yml @@ -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 diff --git a/plugin/federation/examples/node1_config.yml b/plugin/federation/examples/node1_config.yml index a2e92aed..d87856de 100644 --- a/plugin/federation/examples/node1_config.yml +++ b/plugin/federation/examples/node1_config.yml @@ -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 @@ -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. diff --git a/plugin/federation/examples/node2_config.yml b/plugin/federation/examples/node2_config.yml index d54d73fe..843def82 100644 --- a/plugin/federation/examples/node2_config.yml +++ b/plugin/federation/examples/node2_config.yml @@ -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 @@ -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.