[clj-gandi "0.1.3"]
clj-gandi is a clojure wrapper on Gandi.net XML-RPC API.
It's designed to maintain a consistent and resilient RPC stream :
- Use a workers pool based on async channels.
- Compliant with API rate limits
- Auto-requeueing on failure, with loop handling.
- Circuit breaker allowing your application to survive API outages.
- Integrated hystrix metrics server (optional).
GANDI_LOG_LEVEL="debug" GANDI_API_KEY="thetestapikey" lein repl
GANDI_API_KEY="theprodapikey" GANDI_PROD=1 lein run
GANDI_API_KEY
api key, required.
GANDI_API_TIMEOUT_MS
rpc calls timeout in milliseconds, defaults to 30s.
GANDI_API_RETRY_COUNT
rpc calls retry count when rpc fault or timeout, defaults to 5.
GANDI_PROD
use production api, set to 1 for production, use OT&E api if unset or 0.
GANDI_LOG_LEVEL
log level, "debug","info","warn","error", defaults to "warn".
(ns test
(require
[clj-gandi.core]
[clj-gandi.hystrix.server]))
;;;launch workers pool, only once !
(defonce gandi-pool (clj-gandi.core/initialize))
;;;launch metrics server for hystrix dashboard / turbine, on port 5000
(clj-gandi.hystrix.server/run 5000)
;;;simple call
(clj-gandi.core/call :version.info)
;;;simple call, 1000 times
(repeatedly 1000 #(clj-gandi.core/call :version.info))
;;;get domains count
(clj-gandi.core/call :domain.count)
;;;get all domains list
(clj-gandi.core/list-all :domain.list)
;;;get all running servers list (does not work on OT&E API)
(clj-gandi.core/list-all :hosting.vm.list {:state "running"})
Introspection methods have a different prototype, and are rarely used. Instead of adding extra tests on each api call, specific helpers methods are provided.
(clj-gandi.core/methods-list)
(clj-gandi.core/method-help :domain.info)
(clj-gandi.core/method-signature :domain.list)
Latest tests with default config values shows a ~13 req/sec rpc call rate average. Keep in mind that speed is rate-limited per gandi API policy (30 calls per 2 seconds).
- Better unit tests, examples and documentation.
- Improve the API with higher level functions, à la Gandi.cli
- To all the bullshitless Gandi tech and support team.
- To Joseph Wilk for his inspiring blog entry introducing using Hystrix with clojure