DrmagicE / gmqtt

Gmqtt is a flexible, high-performance MQTT broker library that fully implements the MQTT protocol V3.x and V5 in golang
MIT License
989 stars 220 forks source link

Import project with go get #158

Closed xorduna closed 2 years ago

xorduna commented 2 years ago

Hi!

We would like to use gmqtt as our mqtt broker with some plugins to integrate it with our existing application.

We have seen that if we do "go get github.com/DrmagicE/gmqtt" only the folder pkg is imported. We have seen this command in v0.1.1.

How would you recommend to integrate gmqtt into an existing project as a library?

Thank you very much!

Xavi

DrmagicE commented 2 years ago

@xorduna Hi, how about git clone the repository instead of using go get, because now gmqtt is intended to be used as an application rather than a library. However, if you want to import gmqtt as a library, go get github.com/DrmagicE/gmqtt@v0.4.1 should work, but you may take a look into the cmd folder to learn how to build a gmqtt server.

FYI:

The examples folder is outdated. It is recommended to use the gmqtt as an application and leverage the plugin system to custom and extend the capabilities if required, rather than import it as a building block for your own binary.

Using gmqtt as a go package is possible but required additional knowledge about the codebase which may bring you troubles. https://github.com/DrmagicE/gmqtt/pull/143#issue-1048738705

xorduna commented 2 years ago

Hi @DrmagicE!

First of all, thank you so much for such quick answer! The main reason to use it as a library was to do the development of our plugin in the same repo as the main application.

What I am worried about doing a git clone is how we keep the track of the original project while having our own plugins implemented in their own repo.

In any case we will explore options from there.

Thanks!

Xavi

zhoujinfu commented 2 years ago

I have created some gmqtt plugins before. it seems that there is no any graceful way to develop a brand new plugin without the main binary. But we can develop our own plugins on a forked repo and test it in the main binary. The only way to keep the track of the origin repo is use a new remote url and merge from the new remote repeatedly :

e.g: remote named github

  1. git remote set-url github git@github.com:DrmagicE/gmqtt.git when forked the repo.
  2. develop & test your plugins in your fork.
  3. merge from the remote origin git pull github master
zhoujinfu commented 2 years ago

btw, it will be cool to keep the binary separate from library.