fhmq / hmq

High performance mqtt broker
Apache License 2.0
1.32k stars 273 forks source link

Added in GET /connections to update restarting node #176

Closed spit4520 closed 9 months ago

spit4520 commented 1 year ago

During a temporary service re-hydration, this allows the recovering service to:

1.) Sub to /connections for all incoming connections then 2.) Get a list of all connections that exist rn.

This is useful for rebuilding caches and if any of your edge-workers need to be restarted, they can. It also allows for you not to have a 100% coupling in Redis or any other MQ stream. There are still no routes for the MQ streams to get all conns on connect, when we migrate to this we will add in this support as well.

Also cleaned up some routing patters in Gin, added in some constants to make it cleaner to add a lot of REST routes later.

Also added in new type "resp" to push down the values over json, use the omitempty tag to tell encoding/json to ignore this field.

Pro tip: if you have a struct nested in an omitempty field and you don't want it to be serialized. Make it a * golang by default treats these as "nil" and won't serialize them if they are not defined

spit4520 commented 1 year ago

Hi @deadprogram how do you want me to produce a unit test for this? I'd like to upstream this feature and a few others and move off of our internal version

deadprogram commented 1 year ago

Hello @spit4520 you should ask one of the actual maintainers that question :smiley_cat:

cc @chowyu08

spit4520 commented 1 year ago

Hi @chowyu08 do you have any issues with this pull :smile_cat:

spit4520 commented 9 months ago

Hi @chowyu08 I've added in some more verbose information to the broker. I've expanded the information out to include the last will topic, keep alive time, and credentials. This is to create a faux client from one broker to another, but also to allow the application level to keep track of the keepalive time and last message time which can be used for connection and health monitoring

chowyu12 commented 9 months ago

LGTM