Skip to content

Commit

Permalink
feat: add call() method to CircuitBreaker (#374)
Browse files Browse the repository at this point in the history
This allows callers to control the `this` context when firing a circuit breaker function.

Fixes: #349
  • Loading branch information
lance authored Sep 24, 2019
1 parent 79bb2f9 commit ef05d2b
Show file tree
Hide file tree
Showing 5 changed files with 346 additions and 113 deletions.
111 changes: 109 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ <h3 class='mb0 no-anchor'>opossum</h3>
#fire
</a></li>

<li><a
href='#circuitbreakercall'
class='regular pre-open'>
#call
</a></li>

<li><a
href='#circuitbreakerclearcache'
class='regular pre-open'>
Expand Down Expand Up @@ -1764,7 +1770,7 @@ <h3 class='fl m0' id='circuitbreaker'>
<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'>fire()</span>
<span class='code strong strong truncate'>fire(args)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
Expand All @@ -1776,8 +1782,85 @@ <h3 class='fl m0' id='circuitbreaker'>
returned promise will be rejected. If the action succeeds, the promise will
resolve with the resolved value from action. If a fallback function was
provided, it will be invoked in the event of any failure or timeout.</p>
<p>Any parameters passed to this function will be proxied to the circuit
function.</p>

<div class='pre p1 fill-light mt0'>fire(args: ...any): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;any></div>











<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>

<div class='space-bottom0'>
<div>
<span class='code bold'>args</span> <code class='quiet'>(...any)</code>

</div>

</div>

</div>






<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;any></code>:
promise resolves with the circuit function's return
value on success or is rejected on failure of the action.
















</section>

</div>
</div>

<div class='border-bottom' id='circuitbreakercall'>
<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'>call(context, rest)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>



<p>Execute the action for this circuit using <code>context</code> as <code>this</code>.
If the action fails or times out, the
returned promise will be rejected. If the action succeeds, the promise will
resolve with the resolved value from action. If a fallback function was
provided, it will be invoked in the event of any failure or timeout.</p>
<p>Any parameters in addition to `context will be passed to the
circuit function.</p>

<div class='pre p1 fill-light mt0'>fire(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;any></div>
<div class='pre p1 fill-light mt0'>call(context: any, rest: ...any): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;any></div>



Expand All @@ -1789,6 +1872,30 @@ <h3 class='fl m0' id='circuitbreaker'>



<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>

<div class='space-bottom0'>
<div>
<span class='code bold'>context</span> <code class='quiet'>(any)</code>
the
<code>this</code>
context used for function execution

</div>

</div>

<div class='space-bottom0'>
<div>
<span class='code bold'>rest</span> <code class='quiet'>(...any)</code>

</div>

</div>

</div>




Expand Down
Loading

0 comments on commit ef05d2b

Please sign in to comment.