-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use predefined channel configurations
- Loading branch information
Showing
9 changed files
with
135 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ pom.xml.asc | |
/.clj-kondo/ | ||
/profile.json | ||
/.lsp/ | ||
/config.edn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{:client {:client-name "MY_CLIENT" | ||
:user "TESTUSER" | ||
:url "https://ORG_ID-ACCOUNT_ID.snowflakecomputing.com:443" | ||
:private-key "-----BEGIN PRIVATE KEY-----\nMII...\n-----END PRIVATE KEY-----\n" | ||
:port 443 | ||
:host "ORG_ID-ACCOUNT_ID.snowflakecomputing.com" | ||
:scheme "https" | ||
:role "TESTROLE"} | ||
:channels [{:chan-name "my_channel" | ||
:database "TESTDATABASE" | ||
:schema "PUBLIC" | ||
:table "TESTTABLE" | ||
:on-error :continue} | ||
{:chan-name "my_channel2" | ||
:database "TESTDATABASE" | ||
:schema "PUBLIC" | ||
:table "TESTTABLE2" | ||
:on-error :abort}] | ||
:server {:host "0.0.0.0" | ||
:port 9099}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
(ns emqx.config | ||
(:require | ||
[clojure.edn :as edn] | ||
[clojure.java.io :as io] | ||
[schema.coerce :as coerce] | ||
[schema.core :as s])) | ||
|
||
(s/defschema ClientConfig | ||
{:client-name s/Str | ||
:user s/Str | ||
:url s/Str | ||
:private-key s/Str | ||
:port s/Num | ||
:host s/Str | ||
:scheme s/Str | ||
:role s/Str}) | ||
|
||
(s/defschema ChannelConfig | ||
{:chan-name s/Str | ||
:database s/Str | ||
:schema s/Str | ||
:table s/Str | ||
:on-error (s/enum :continue :abort)}) | ||
|
||
(s/defschema ServerConfig | ||
{:host s/Str | ||
:port s/Num}) | ||
|
||
(s/defschema EMQXConfig | ||
{:client ClientConfig | ||
:channels [ChannelConfig] | ||
:server ServerConfig}) | ||
|
||
(defn get-config! | ||
"Get the configurations for startup. | ||
That config is read from a `config.edn` file in the app's working | ||
directory." | ||
[] | ||
(let [params (with-open [r (io/reader "config.edn")] | ||
(edn/read (java.io.PushbackReader. r))) | ||
coercer (coerce/coercer! EMQXConfig coerce/keyword-enum-matcher) | ||
config (coercer params) | ||
app-name (or (System/getenv "APP_NAME") | ||
(str (java.util.UUID/randomUUID)))] | ||
(assoc config :app-name app-name))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters