mirror of
https://github.com/edufeed-org/amb-publisher.git
synced 2025-12-07 23:34:35 +00:00
make relay configurable
This commit is contained in:
parent
3088f54904
commit
cb1b94b1a6
3 changed files with 16 additions and 12 deletions
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
Publishes AMB data from a json-file to some relay.
|
||||
|
||||
`clj -X publisher.core/process-json-lines-file :path resources/oersi_data.jsonl`
|
||||
|
||||
`clj -X publisher.core/run :path "resources/oersi_data.jsonl" :relay "ws://localhost:10547"`
|
||||
|
||||
## TODO
|
||||
|
||||
- [ ] make relay configurable
|
||||
- [X] make relay configurable
|
||||
- [ ] enable multiple relays
|
||||
|
|
|
|||
6
deps.edn
6
deps.edn
|
|
@ -1,5 +1,7 @@
|
|||
{:deps {clj-http/clj-http {:mvn/version "3.13.0"}
|
||||
{:deps {org.clojure/clojure {:mvn/version "1.12.0"}
|
||||
org.clojure/core.async {:mvn/version "1.6.673"}
|
||||
clj-http/clj-http {:mvn/version "3.13.0"}
|
||||
cheshire/cheshire {:mvn/version "5.13.0"}
|
||||
hato/hato {:mvn/version "1.0.0"}
|
||||
nostr/nostr {:local/root "/home/steffen/coding/nostr-clj"}}}
|
||||
net.clojars.laoc/nostr {:mvn/version "0.0.7"}}}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
[hato.websocket :as ws]
|
||||
[cheshire.core :as json]))
|
||||
|
||||
(defn create-websocket []
|
||||
(defn create-websocket [relay]
|
||||
;; Create the WebSocket connection and return it
|
||||
(let [ws @(ws/websocket "ws://localhost:7778"
|
||||
(let [ws @(ws/websocket relay
|
||||
{:on-message (fn [ws msg last?]
|
||||
(when last?
|
||||
(println msg)))
|
||||
|
|
@ -27,13 +27,15 @@
|
|||
(defn process-json-line [raw-event]
|
||||
(save-to-jsonl raw-event "events.jsonl"))
|
||||
|
||||
(defn process-json-lines-file [file-path]
|
||||
(let [ws (create-websocket)]
|
||||
(with-open [reader (io/reader "resources/oersi_data.jsonl")]
|
||||
(defn process-json-lines-file [file-path relay]
|
||||
(let [ws (create-websocket relay)]
|
||||
(with-open [reader (io/reader file-path)]
|
||||
(doseq [line (line-seq reader)]
|
||||
(let [json-data (json/parse-string line true)
|
||||
raw-event (edufeed/transform-amb-to-30142-event (:_source json-data))
|
||||
]
|
||||
raw-event (edufeed/transform-amb-to-30142-event (:_source json-data))]
|
||||
(process-json-line raw-event)
|
||||
(send-to-relay ws raw-event))))))
|
||||
|
||||
(defn run [{:keys [path relay]}]
|
||||
(println "Args:" path relay)
|
||||
(process-json-lines-file path relay ))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue