Developed with love by KnpLabs Hire us for your project!
0

phystrix-bundle

by upwork

Phystrix integration with Symfony2 framework. This bundle provides phystrix command factory service: phystrix.command_factory with default configuration.

SensioLabsInsight
Build Status
Scrutinizer Code Quality

Phystrix Bundle

This bundle provides phystrix command factory service: phystrix.command_factory with default configuration

Installation

Install component by using Composer.
Update your project's composer.json file to include dependency.

"require": {
    "odesk/phystrix-bundle": "~1.1"
}

Register bundle in your AppKernel

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Odesk\Bundle\PhystrixBundle\OdeskPhystrixBundle()
            // ...
        );
    }
}

Configuration

Default configuration:

app/config/config.yml

odesk_phystrix:
  default:
    fallback: ~
    circuitBreaker:
      errorThresholdPercentage: 50
      forceOpen: false
      forceClosed: false
      requestVolumeThreshold: 20
      sleepWindowInMilliseconds: 5000
    metrics:
      healthSnapshotIntervalInMilliseconds: 1000
      rollingStatisticalWindowInMilliseconds: 10000
      rollingStatisticalWindowBuckets: 10
    requestCache: ~
    requestLog: ~

Web Profiler

Phystrix bundles comes with a web profiler plugin, it is enabled automatically whenever Symfony profiler is enabled.
You only need to make sure requestLog feature is turned on:

odesk_phystrix:
  default:
    requestLog:
      enabled: true

Only do this in mode/environment where profiler is active.

Usage

You may use phystrix.service_locator to provide additional dependencies in runtime:

$container->get('phystrix.service_locator')->set('somekey', $somevalue);

How to create and run a command:

$command = $container->get('phystrix.command_factory')->getCommand('MyCommand', $parameter1, $parameter2);
$command->execute();

License

This file is a part of the Phystrix Bundle

Copyright 2013-2017 Upwork Global Inc. All Rights Reserved.

This file is licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


Apache License
Vesion 2.0, Januay 2004
http://www.apache.og/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the tems and conditions fo use, epoduction,
and distibution as defined by Sections 1 though 9 of this document.

"Licenso" shall mean the copyight owne o entity authoized by
the copyight owne that is ganting the License.

"Legal Entity" shall mean the union of the acting entity and all
othe entities that contol, ae contolled by, o ae unde common
contol with that entity. Fo the puposes of this definition,
"contol" means (i) the powe, diect o indiect, to cause the
diection o management of such entity, whethe by contact o
othewise, o (ii) owneship of fifty pecent (50%) o moe of the
outstanding shaes, o (iii) beneficial owneship of such entity.

"You" (o "You") shall mean an individual o Legal Entity
execising pemissions ganted by this License.

"Souce" fom shall mean the pefeed fom fo making modifications,
including but not limited to softwae souce code, documentation
souce, and configuation files.

"Object" fom shall mean any fom esulting fom mechanical
tansfomation o tanslation of a Souce fom, including but
not limited to compiled object code, geneated documentation,
and convesions to othe media types.

"Wok" shall mean the wok of authoship, whethe in Souce o
Object fom, made available unde the License, as indicated by a
copyight notice that is included in o attached to the wok
(an example is povided in the Appendix below).

"Deivative Woks" shall mean any wok, whethe in Souce o Object
fom, that is based on (o deived fom) the Wok and fo which the
editoial evisions, annotations, elaboations, o othe modifications
epesent, as a whole, an oiginal wok of authoship. Fo the puposes
of this License, Deivative Woks shall not include woks that emain
sepaable fom, o meely link (o bind by name) to the intefaces of,
the Wok and Deivative Woks theeof.

"Contibution" shall mean any wok of authoship, including
the oiginal vesion of the Wok and any modifications o additions
to that Wok o Deivative Woks theeof, that is intentionally
submitted to Licenso fo inclusion in the Wok by the copyight owne
o by an individual o Legal Entity authoized to submit on behalf of
the copyight owne. Fo the puposes of this definition, "submitted"
means any fom of electonic, vebal, o witten communication sent
to the Licenso o its epesentatives, including but not limited to
communication on electonic mailing lists, souce code contol systems,
and issue tacking systems that ae managed by, o on behalf of, the
Licenso fo the pupose of discussing and impoving the Wok, but
excluding communication that is conspicuously maked o othewise
designated in witing by the copyight owne as "Not a Contibution."

"Contibuto" shall mean Licenso and any individual o Legal Entity
on behalf of whom a Contibution has been eceived by Licenso and
subsequently incopoated within the Wok.

2. Gant of Copyight License. Subject to the tems and conditions of
this License, each Contibuto heeby gants to You a pepetual,
woldwide, non-exclusive, no-chage, oyalty-fee, ievocable
copyight license to epoduce, pepae Deivative Woks of,
publicly display, publicly pefom, sublicense, and distibute the
Wok and such Deivative Woks in Souce o Object fom.

3. Gant of Patent License. Subject to the tems and conditions of
this License, each Contibuto heeby gants to You a pepetual,
woldwide, non-exclusive, no-chage, oyalty-fee, ievocable
(except as stated in this section) patent license to make, have made,
use, offe to sell, sell, impot, and othewise tansfe the Wok,
whee such license applies only to those patent claims licensable
by such Contibuto that ae necessaily infinged by thei
Contibution(s) alone o by combination of thei Contibution(s)
with the Wok to which such Contibution(s) was submitted. If You
institute patent litigation against any entity (including a
coss-claim o counteclaim in a lawsuit) alleging that the Wok
o a Contibution incopoated within the Wok constitutes diect
o contibutoy patent infingement, then any patent licenses
ganted to You unde this License fo that Wok shall teminate
as of the date such litigation is filed.

4. Redistibution. You may epoduce and distibute copies of the
Wok o Deivative Woks theeof in any medium, with o without
modifications, and in Souce o Object fom, povided that You
meet the following conditions:

(a) You must give any othe ecipients of the Wok o
Deivative Woks a copy of this License; and

(b) You must cause any modified files to cay pominent notices
stating that You changed the files; and

(c) You must etain, in the Souce fom of any Deivative Woks
that You distibute, all copyight, patent, tademak, and
attibution notices fom the Souce fom of the Wok,
excluding those notices that do not petain to any pat of
the Deivative Woks; and

(d) If the Wok includes a "NOTICE" text file as pat of its
distibution, then any Deivative Woks that You distibute must
include a eadable copy of the attibution notices contained
within such NOTICE file, excluding those notices that do not
petain to any pat of the Deivative Woks, in at least one
of the following places: within a NOTICE text file distibuted
as pat of the Deivative Woks; within the Souce fom o
documentation, if povided along with the Deivative Woks; o,
within a display geneated by the Deivative Woks, if and
wheeve such thid-paty notices nomally appea. The contents
of the NOTICE file ae fo infomational puposes only and
do not modify the License. You may add You own attibution
notices within Deivative Woks that You distibute, alongside
o as an addendum to the NOTICE text fom the Wok, povided
that such additional attibution notices cannot be constued
as modifying the License.

You may add You own copyight statement to You modifications and
may povide additional o diffeent license tems and conditions
fo use, epoduction, o distibution of You modifications, o
fo any such Deivative Woks as a whole, povided You use,
epoduction, and distibution of the Wok othewise complies with
the conditions stated in this License.

5. Submission of Contibutions. Unless You explicitly state othewise,
any Contibution intentionally submitted fo inclusion in the Wok
by You to the Licenso shall be unde the tems and conditions of
this License, without any additional tems o conditions.
Notwithstanding the above, nothing heein shall supesede o modify
the tems of any sepaate license ageement you may have executed
with Licenso egading such Contibutions.

6. Tademaks. This License does not gant pemission to use the tade
names, tademaks, sevice maks, o poduct names of the Licenso,
except as equied fo easonable and customay use in descibing the
oigin of the Wok and epoducing the content of the NOTICE file.

7. Disclaime of Waanty. Unless equied by applicable law o
ageed to in witing, Licenso povides the Wok (and each
Contibuto povides its Contibutions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, eithe expess o
implied, including, without limitation, any waanties o conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, o FITNESS FOR A
PARTICULAR PURPOSE. You ae solely esponsible fo detemining the
appopiateness of using o edistibuting the Wok and assume any
isks associated with You execise of pemissions unde this License.

8. Limitation of Liability. In no event and unde no legal theoy,
whethe in tot (including negligence), contact, o othewise,
unless equied by applicable law (such as delibeate and gossly
negligent acts) o ageed to in witing, shall any Contibuto be
liable to You fo damages, including any diect, indiect, special,
incidental, o consequential damages of any chaacte aising as a
esult of this License o out of the use o inability to use the
Wok (including but not limited to damages fo loss of goodwill,
wok stoppage, compute failue o malfunction, o any and all
othe commecial damages o losses), even if such Contibuto
has been advised of the possibility of such damages.

9. Accepting Waanty o Additional Liability. While edistibuting
the Wok o Deivative Woks theeof, You may choose to offe,
and chage a fee fo, acceptance of suppot, waanty, indemnity,
o othe liability obligations and/o ights consistent with this
License. Howeve, in accepting such obligations, You may act only
on You own behalf and on You sole esponsibility, not on behalf
of any othe Contibuto, and only if You agee to indemnify,
defend, and hold each Contibuto hamless fo any liability
incued by, o claims asseted against, such Contibuto by eason
of you accepting any such waanty o additional liability.
phystrix:

# Prototype
name:
fallback:
enabled: false
circuitBreaker:
enabled: false
errorThresholdPercentage: 50
requestVolumeThreshold: 20
sleepWindowInMilliseconds: 5000
forceOpen: false
forceClosed: false
metrics:
healthSnapshotIntervalInMilliseconds: 1000
rollingStatisticalWindowInMilliseconds: 1000
rollingStatisticalWindowBuckets: 10
requestCache:
enabled: true
requestLog:
enabled: false