Skip to content

Commit

Permalink
Merge pull request #8 from thalesmg/clean-start
Browse files Browse the repository at this point in the history
feat(mqtt): add option to set `:clean-start`
  • Loading branch information
thalesmg authored Oct 23, 2024
2 parents 22cabd2 + deb34fb commit 2b9ea1a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions config.example.edn
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
:port 1883
:clientid "chan1"
:topic "t/sf/1"
:qos 1}}
:qos 1
:clean-start false}}
{:chan-name "my_channel2"
:database "TESTDATABASE"
:schema "PUBLIC"
Expand All @@ -24,4 +25,5 @@
:port 1883
:clientid "chan2"
:topic "t/sf/2"
:qos 1}}]}
:qos 1
:clean-start false}}]}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ java -jar target/emqx-snowflake-proxy-0.0.0-standalone.jar
```bash
docker build . -t emqx/emqx-snowflake-proxy
docker run -v ./config.edn:/usr/src/app/config.edn emqx/emqx-snowflake-proxy
docker run -v ./config.edn:/opt/proxy/config.edn ghcr.io/emqx/emqx-snowflake-proxy
```
## testing
Expand Down
5 changes: 3 additions & 2 deletions src/emqx/adapter.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
[cheshire.core :as json]))

(defn mqtt-client-config
[{:keys [:host :port :clientid :topic :qos :username :password]}]
[{:keys [:host :port :clientid :topic :qos :clean-start :username :password]}]
{:uri (str "tcp://" host ":" port)
:clientid clientid
:topic topic
:qos qos
:opts (cond-> {:auto-reconnect true}
username (assoc :username username)
password (assoc :password password))})
password (assoc :password password)
(boolean? clean-start) (assoc :clean-session clean-start))})

(defn channel-data-in
"Parses the incoming payload and expects it to be a JSON encoded object"
Expand Down
1 change: 1 addition & 0 deletions src/emqx/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
:clientid s/Str
:topic s/Str
:qos (s/enum 0 1 2)
(s/optional-key :clean-start) s/Bool
(s/optional-key :username) s/Str
(s/optional-key :password) s/Str})

Expand Down

0 comments on commit 2b9ea1a

Please sign in to comment.