Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mqtt): add option to set :clean-start #8

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading