project.clj
[updcon/libpinkas-clj "0.0.5"]
example.clj
(ns my-app.jasper
(:require [libpinkas-clj.core :refer :all]
[clojure.core.async :refer [timeout <!!] :include-macros true]))
(defn- schema [id port]
{:node "My-Node-Name"
:address "127.0.0.1"
:service {
:id id
:name id
:service "my-service"
:address "127.0.0.1"
:tags ["primary"]
:enable_tag_override true
:port port}
})
(def ^:private path "http://localhost:8500/v1/catalog/")
(def ^:private serv1 (service path (schema "my-service-1" 8888)))
(def ^:private one-sec 1000)
(defn run-my-service
(let [status (register serv1)]
(when status
(<!! (timeout one-sec)))
(assert (= (count (filter
#(= "my-service-1" (get % :ServiceID))
(discover serv1))) 1)))
(deregister serv1)
(<!! (timeout one-sec)))
==> Starting Consul agent...
Version: '1.8.4'
Node ID: '25c675d4-ce4a-c35b-420f-d8ff12469a5f'
Node name: 'localhost.localdomain'
Datacenter: 'dc1' (Segment: '<all>')
Server: true (Bootstrap: false)
Client Addr: [127.0.0.1] (HTTP: 8500, HTTPS: -1, gRPC: 8502, DNS: 8600)
Cluster Addr: 127.0.0.1 (LAN: 8301, WAN: 8302)
Encrypt: Gossip: false, TLS-Outgoing: false, TLS-Incoming: false, Auto-Encrypt-TLS: false
..............
==> Consul agent running!