Skip to content

Commit

Permalink
doc: update docs with latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lance committed Aug 21, 2019
1 parent a1b10b9 commit aab8048
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 190 deletions.
87 changes: 6 additions & 81 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ <h3 class='mb0 no-anchor'>opossum</h3>

<div class='toggle-target display-none'>

<ul class='list-reset py1-ul pl1'>
<li class='h5'><span>Static members</span></li>

<li><a
href='#circuitbreakercircuits'
class='regular pre-open'>
.circuits
</a></li>

</ul>


<ul class='list-reset py1-ul pl1'>
<li class='h5'><span>Instance members</span></li>
Expand Down Expand Up @@ -517,7 +506,7 @@ <h3>Browser</h3>
}
}
});</pre>
<p>In the browser's global scope will be a <code>circuitBreaker</code> function. Use it
<p>In the browser's global scope will be a <code>CircuitBreaker</code> constructor. Use it
to create circuit breakers, guarding against network failures in your REST
API calls.</p>
<pre class='hljs'><span class="hljs-comment">// app.js</span>
Expand All @@ -528,7 +517,7 @@ <h3>Browser</h3>
<span class="hljs-attr">resetTimeout</span>: <span class="hljs-number">5000</span>
};

<span class="hljs-keyword">const</span> circuit = circuitBreaker(<span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> $.<span class="hljs-keyword">get</span>(route), circuitBreakerOptions);
<span class="hljs-keyword">const</span> circuit = <span class="hljs-keyword">new</span> CircuitBreaker(<span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> $.<span class="hljs-keyword">get</span>(route), circuitBreakerOptions);
circuit.fallback(() =&gt; `${route} unavailable right now. Try later.<span class="hljs-string">`));
circuit.on('success', (result) =&gt; $(element).append(JSON.stringify(result)}));

Expand All @@ -552,7 +541,7 @@ <h3>Events</h3>
<li><code>healthCheckFailed</code> - emitted when a user-supplied health check function returns a rejected promise</li>
</ul>
<p>Handling events gives a greater level of control over your application behavior.</p>
<pre class='hljs'><span class="hljs-keyword">const</span> circuit = circuitBreaker(<span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> $.<span class="hljs-keyword">get</span>(route), circuitBreakerOptions);
<pre class='hljs'><span class="hljs-keyword">const</span> circuit = <span class="hljs-keyword">new</span> CircuitBreaker(<span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> $.<span class="hljs-keyword">get</span>(route), circuitBreakerOptions);

circuit.fallback(() =&gt; ({ body: <span class="hljs-string">`<span class="hljs-subst">${route}</span> unavailable right now. Try later.`</span> }));

Expand Down Expand Up @@ -591,17 +580,17 @@ <h3>Promises vs. Callbacks</h3>
Node core utility function <code>util.promisify()</code> .</p>
<pre class='hljs'><span class="hljs-keyword">const</span> fs = <span class="hljs-built_in">require</span>(<span class="hljs-string">'fs'</span>);
<span class="hljs-keyword">const</span> { promisify } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'util'</span>);
<span class="hljs-keyword">const</span> circuitBreaker = <span class="hljs-built_in">require</span>(<span class="hljs-string">'opossum'</span>);
<span class="hljs-keyword">const</span> CircuitBreaker = <span class="hljs-built_in">require</span>(<span class="hljs-string">'opossum'</span>);

<span class="hljs-keyword">const</span> readFile = promisify(fs.readFile);
<span class="hljs-keyword">const</span> breaker = circuitBreaker(readFile, options);
<span class="hljs-keyword">const</span> breaker = <span class="hljs-keyword">new</span> CircuitBreaker(readFile, options);

breaker.fire(<span class="hljs-string">'./package.json'</span>, <span class="hljs-string">'utf-8'</span>)
.then(<span class="hljs-built_in">console</span>.log)
.catch(<span class="hljs-built_in">console</span>.error);</pre>
<p>And just for fun, your circuit doesn't even really have to be a function.
Not sure when you'd use this - but you could if you wanted to.</p>
<pre class='hljs'><span class="hljs-keyword">const</span> breaker = circuitBreaker(<span class="hljs-string">'foo'</span>, options);
<pre class='hljs'><span class="hljs-keyword">const</span> breaker = <span class="hljs-keyword">new</span> CircuitBreaker(<span class="hljs-string">'foo'</span>, options);

breaker.fire()
.then(<span class="hljs-built_in">console</span>.log) <span class="hljs-comment">// logs 'foo'</span>
Expand Down Expand Up @@ -882,70 +871,6 @@ <h3 class='fl m0' id='circuitbreaker'>



<div class='py1 quiet mt1 prose-big'>Static Members</div>
<div class="clearfix">

<div class='border-bottom' id='circuitbreakercircuits'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>circuits()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>



<p>Gets a Set iterator of all active circuits. If a circuit
has been created, but subsequently shut down, it will not
be included in the Set iterator.</p>

<div class='pre p1 fill-light mt0'>circuits(): Iterator</div>
















<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>Iterator</code>:
an Iterator object containing a reference
to all {CircuitBreaker} instances that have been created.
















</section>

</div>
</div>

</div>




<div class='py1 quiet mt1 prose-big'>Instance Members</div>
Expand Down
Loading

0 comments on commit aab8048

Please sign in to comment.