forked from Netflix/Hystrix
-
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.
Experimental Clojure bindings for Hystrix
- Loading branch information
Showing
7 changed files
with
984 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Hystrix Clojure Bindings | ||
|
||
This module contains idiomatic Clojure bindings for Hystrix. | ||
|
||
# Binaries | ||
|
||
Binaries and dependency information for Maven, Ivy, Gradle and others can be found at [http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22hystrix-clj%22). | ||
|
||
Example for Maven: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.netflix.hystrix</groupId> | ||
<artifactId>hystrix-clj</artifactId> | ||
<version>x.y.z</version> | ||
</dependency> | ||
``` | ||
|
||
and for Ivy: | ||
|
||
```xml | ||
<dependency org="com.netflix.hystrix" name="hystrix-clj" rev="x.y.z" /> | ||
``` | ||
|
||
and for Leiningen: | ||
|
||
```clojure | ||
[com.netflix.hystrix/hystrix-clj "x.y.z"] | ||
``` | ||
|
||
# Usage | ||
|
||
Please see the docstrings in src/com/netflix/hystrix/core.clj for extensive usage info. | ||
|
||
## TL;DR | ||
You have a function that interacts with an untrusted dependency: | ||
|
||
```clojure | ||
(defn make-request | ||
[arg] | ||
... make the request ...) | ||
|
||
; execute the request | ||
(make-request \"baz\") | ||
``` | ||
|
||
and you want to make it a Hystrix dependency command. Do this: | ||
|
||
```clojure | ||
(defcommand make-request | ||
[arg] | ||
... make the request ...) | ||
|
||
; execute the request | ||
(make-request \"baz\") | ||
|
||
; or queue for async execution | ||
(queue #'make-request \"baz\") | ||
``` | ||
|
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,37 @@ | ||
buildscript { | ||
repositories { | ||
mavenRepo name: 'clojars', url: 'http://clojars.org/repo' | ||
} | ||
dependencies { | ||
classpath 'clojuresque:clojuresque:1.5.5' | ||
} | ||
} | ||
apply plugin: 'clojure' | ||
|
||
repositories { | ||
mavenCentral() | ||
clojarsRepo() | ||
} | ||
|
||
dependencies { | ||
compile project(':hystrix-core') | ||
compile 'org.clojure:clojure:1.4.0' | ||
} | ||
|
||
// This is a bit of a hack to get a copy of the classpath so I can use | ||
// Leiningen to get a nrepl server going. One day Clojuresque might support it. | ||
task outputClasspath { | ||
def outputFile = new File('runtimeClasspath') | ||
dependsOn classes | ||
// This task is fast, so always running it is ok. | ||
//inputs.files sourceSets.main.runtimeClasspath | ||
//outputs.file outputFile | ||
doFirst { | ||
outputFile.withWriter { | ||
it.write sourceSets.main.runtimeClasspath.asPath | ||
} | ||
} | ||
} | ||
build.dependsOn outputClasspath | ||
|
||
// vim:ft=groovy |
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,22 @@ | ||
; This is a dummy lein project for using nrepl, vimclojure, etc. | ||
(defproject hystrix-clj "0.0.0" | ||
:description "" | ||
:url "" | ||
:license {:name "" | ||
:url "http://netflix.com"} | ||
|
||
; No dependencies here because we rely on Ivy and the :resoure-paths hack below | ||
:dependencies [] | ||
:warn-on-reflection true | ||
|
||
:profiles { | ||
:dev { | ||
:jvm-opts [ ] | ||
:source-paths ["src/main/clojure" "src/test/clojure"] | ||
|
||
; runtimeClasspath is generated by build.gradle | ||
:resource-paths ~(-> "runtimeClasspath" | ||
slurp | ||
(.split ":") | ||
vec) }}) | ||
|
Oops, something went wrong.