This repository has been archived by the owner on Jul 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompositor.json
90 lines (90 loc) · 5.32 KB
/
compositor.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{
"name": "gradeup/ckt-breaker",
"version": "0.1.4",
"libraries": {
"xv": "^1.1.25"
},
"title": "",
"branch": "",
"style": {
"name": "Material",
"componentSet": {
"nav": "nav/DarkAbsoluteNav",
"header": "header/GradientHeader",
"article": "article/BasicArticle",
"footer": "footer/BasicFooter"
},
"fontFamily": "Roboto, sans-serif",
"heading": {
"fontWeight": 500,
"letterSpacing": "-0.01em"
},
"colors": {
"text": "#212121",
"background": "#fff",
"primary": "#2196f3",
"secondary": "#1565c0",
"highlight": "#ff4081",
"border": "#e0e0e0",
"muted": "#f5f5f5"
},
"layout": {
"centered": true,
"bannerHeight": "80vh",
"maxWidth": 896
}
},
"content": [
{
"component": "nav",
"links": [
{
"href": "https://github.com/gradeup/ckt-breaker",
"text": "GitHub"
},
{
"href": "https://npmjs.com/package/ckt-breaker",
"text": "npm"
}
]
},
{
"component": "header",
"heading": "ckt-breaker",
"subhead": "Circuit breaker implementation in < 100 lines ",
"children": [
{
"component": "ui/TweetButton",
"text": "ckt-breaker: Circuit breaker implementation in < 100 lines ",
"url": null
},
{
"component": "ui/GithubButton",
"user": "gradeup",
"repo": "ckt-breaker"
}
],
"text": "v1.0.0"
},
{
"component": "article",
"metadata": {
"source": "github.readme"
},
"html": "\n<blockquote>\n<p>Tiny circuit breaker implementation. Wrapped service must return Promise.</p>\n</blockquote>\n<h2>Requirements</h2>\n<ul>\n<li>node v6+</li>\n<li>npm 3+<h2>Install</h2>\n</li>\n</ul>\n<pre>$ npm <span class=\"hljs-keyword\">install</span> <span class=\"hljs-comment\">--save ckt-breaker</span></pre><h2>Usage</h2>\n<pre><span class=\"hljs-keyword\">const</span> cktBreaker = <span class=\"hljs-built_in\">require</span>(<span class=\"hljs-string\">'ckt-breaker'</span>);\n<span class=\"hljs-comment\">// Function that hits some service </span>\n<span class=\"hljs-keyword\">const</span> fn = <span class=\"hljs-function\"><span class=\"hljs-params\">()</span> =></span> <span class=\"hljs-built_in\">Promise</span>.reject(<span class=\"hljs-string\">'I got nothing'</span>);\n\n<span class=\"hljs-keyword\">const</span> ckt = cktBreaker(fn, {\n <span class=\"hljs-attr\">retry</span>: <span class=\"hljs-number\">10000</span>, <span class=\"hljs-comment\">// time in ms after which to retry hitting fn</span>\n timeout: <span class=\"hljs-number\">1000</span>, <span class=\"hljs-comment\">// time in ms to timeout if fn takes longer than that</span>\n maxError: <span class=\"hljs-number\">10</span>, <span class=\"hljs-comment\">// Max no of errors</span>\n maxTime: <span class=\"hljs-number\">1000</span>, <span class=\"hljs-comment\">// time in ms in which maxError occurs</span>\n fallback: <span class=\"hljs-function\"><span class=\"hljs-params\">()</span> =></span> <span class=\"hljs-built_in\">Promise</span>.reject(<span class=\"hljs-keyword\">new</span> <span class=\"hljs-built_in\">Error</span>(<span class=\"hljs-string\">'Service Currently unavailable'</span>)),\n});\n\nckt.fire(<span class=\"hljs-string\">'hello world'</span>) <span class=\"hljs-comment\">// Safe doesn't overload the remote service</span></pre><h2>API</h2>\n<h3>cktBreaker(fn, {options})</h3>\n<h4>fn</h4>\n<p>Type: <code>function</code></p>\n<p>A promise returning function </p>\n<h4>options</h4>\n<h5>retry</h5>\n<p>Type: <code>integer</code><br>\nDefault: <code>10000</code></p>\n<p>Time in ms after which to retry hitting fn</p>\n<h5>timeout</h5>\n<p>Type: <code>integer</code><br>\nDefault: <code>0</code></p>\n<p>Time in ms to timeout fn if fn takes longer than that.\nBy default this is disabled (0). </p>\n<h5>maxError</h5>\n<p>Type: <code>integer</code><br>\nDefault: <code>10</code></p>\n<p>No of errors in <code>maxTime</code> time to occur before breaking the circuit</p>\n<h5>maxTime</h5>\n<p>Type: <code>integer</code><br>\nDefault: <code>1000</code></p>\n<p>Time Frame to consider maxError no of error to break the circuit</p>\n<h5>fallback</h5>\n<p>Type: <code>function</code><br>\nDefault: <code>() => Promise.reject(new Error('Service Currently unavailable')</code></p>\n<p>Fallback function to call when circuit is broken</p>\n<h3>Methods</h3>\n<h4>fire</h4>\n<pre>const ckt = cktBreaker(fn); \nckt.fire([<span class=\"hljs-number\">1</span>,<span class=\"hljs-number\">2</span>,<span class=\"hljs-number\">3</span>]) <span class=\"hljs-comment\">// Any args taken by fn;</span></pre><p>Function that runs wrapped fn and passes over arguments given to it</p>\n<h3>Events</h3>\n<h4>open</h4>\n<p>Fired when circuit is opened</p>\n<h4>closed</h4>\n<p>Fired when circuit is closed</p>\n<h2>License</h2>\n<p>MIT © <a href=\"http://niksrc.github.io\">Nikhil Srivastava</a></p>\n"
},
{
"component": "footer",
"links": [
{
"href": "https://github.com/gradeup/ckt-breaker",
"text": "GitHub"
},
{
"href": "https://github.com/gradeup",
"text": "gradeup"
}
]
}
]
}