[updcon/libpinkas-clj "0.0.1"]
A Clojure library designed to support basic registry operations for microservices with HashiCorp Consul service.
Heavily inspired by clj-consul-catalog.
[updcon/libpinkas-clj "0.0.1"]
(ns my-app.jasper
(:require [libpinkas-clj.core :refer :all]
[clojure.core.async :refer [timeout <!!] :include-macros true]))
(defn- schema [id port]
{:node "MYNODE-MACADDR"
:address "127.0.0.1"
:service {
:id id
:service "my-service"
:address "127.0.0.1"
:port port}
})
(def ^:private path "http://localhost:8500/v1/catalog/")
(def ^:private s1 (service path (schema "my-service-1" 8888)))
(def ^:private 1s 1000)
(defn run-my-service
(let [status (register s1)]
(when status
(<!! (timeout 1s)))
(assert (= (count (filter
#(= "my-service-1" (get % :ServiceID))
(discover s1))) 1)))
(deregister s1)
(<!! (timeout 1s)))
==> Consul agent running!
Version: 'v1.4.4'
Node ID: '7b50bf01-8e4c-8536-759c-85477ae59855'
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
Run Consul
$ consul agent -dev
Run tests
$ cd /path/to/libpinkas-clj
$ lein test
lein test libpinkas-clj.core-test
Ran 3 tests containing 9 assertions.
0 failures, 0 errors.
Enjoy!
Copyright © 2019 UPD Consulting
Distributed under the MIT License.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close