circuit-b | A non intrusive circuit breaker for node.js | Runtime Evironment library

 by   trygve-lie JavaScript Version: v3.0.0 License: MIT

kandi X-RAY | circuit-b Summary

kandi X-RAY | circuit-b Summary

circuit-b is a JavaScript library typically used in Server, Runtime Evironment applications. circuit-b has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can install using 'npm i circuit-b' or download it from GitHub, npm.

A circuit breaker provides latency and fault protection for distributed systems. A circuit breaker monitor outgoing requests, and will trip an internal circuit if it begins to detect that the remote service is failing. By doing so, one can redirect requests to sane fallbacks, and back-off requests against downstream services so they can recover. This pattern is described in detail in the akka documentation. Circuit-b is non intrusive in the way that one do not need to implement it every single place one do a http call in an application. One only need to init Circuit-b one place in an application and it will intercept all http calls. When that is said; one can init Circuit-b multiple times if wanted. Under the hood Circuit-b use async hooks to intercept http calls on the net socket level so there is no altering of the global http object in node or any global singletons. By using this approach there is a clear separation between the code doing http calls and the code doing circuit breaking.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              circuit-b has a low active ecosystem.
              It has 90 star(s) with 3 fork(s). There are 2 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 2 open issues and 7 have been closed. On average issues are closed in 32 days. There are 7 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of circuit-b is v3.0.0

            kandi-Quality Quality

              circuit-b has no bugs reported.

            kandi-Security Security

              circuit-b has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              circuit-b is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              circuit-b releases are available to install and integrate.
              Deployable package is available in npm.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of circuit-b
            Get all kandi verified functions for this library.

            circuit-b Key Features

            No Key Features are available at this moment for circuit-b.

            circuit-b Examples and Code Snippets

            The length of the circuit .
            pythondot img1Lines of Code : 16dot img1License : Permissive (MIT License)
            copy iconCopy
            def level(self) -> int:
                    """
                    :return: Number of forward references
            
                    >>> node = Node("Key", 2)
                    >>> node.level
                    0
                    >>> node.forward.append(Node("Key2", 4))
                    >>>   
            Initialize the circuit .
            pythondot img2Lines of Code : 6dot img2License : Non-SPDX (Apache License 2.0)
            copy iconCopy
            def __init__(self, c_op, g):
                self._c_op = c_op
                self._graph = g
                self._outputs = None  # Initialized by _duplicate_body_captures_in_cond().
                self._id_value = g._add_op(self, self.name)
                self._is_stateful = False  
            The circuit breaker around a circuit breaker
            javadot img3Lines of Code : 4dot img3License : Permissive (MIT License)
            copy iconCopy
            @Around("@annotation(com.baeldung.hystrix.HystrixCircuitBreaker)")
                public Object circuitBreakerAround(final ProceedingJoinPoint aJoinPoint) {
                    return new RemoteServiceCommand(config, aJoinPoint).execute();
                }  

            Community Discussions

            QUESTION

            Circuit breaker for asynchronous microservices..?
            Asked 2021-Jun-01 at 09:43

            There is a ActiveMQ queue (QueueA). A service (MyService) subscribes to messages, processes it and sends the message to another ActiveMQ queue (QueueB).

            ...

            ANSWER

            Answered 2021-Jun-01 at 09:43

            Have a look on the Camel RoutePolicy of type ThrottlingExceptionRoutePolicy which is based on the CircuitBreakerLoadBalancer.

            Using this policy should allow you to stop consuming from the endpoint when the circuit is in the open state (to compare with the standard circuit behahiour : bypass the service call, and fallback to another response).

            Source https://stackoverflow.com/questions/67783419

            QUESTION

            How to skip retry in vertx circuit breaker based on condition
            Asked 2021-May-24 at 04:58

            I am currently using Vertx CircuitBreaker to attempt retry on requesting event bus. Based on the ReplyException.ReplyFailure I want to skip or avoid retries.

            For example I don't want retry when the event bus responds with ReplyFailure.RECIPIENT_FAILURE, because this kind of error are not application error instead logic validation failure.

            Below is my code,

            ...

            ANSWER

            Answered 2021-May-21 at 15:55

            This is not currently supported by the Vert.x Circuit Breaker API. There is an open issue about it here. There's also a PR that attempts to fix it, but it has been sitting around for a year now. Not sure why it never got reviewed.

            Source https://stackoverflow.com/questions/67639186

            QUESTION

            How to sync two Azure blobs on two different accounts on schedule time?
            Asked 2021-Mar-12 at 07:20

            In order to achieve High Availability we have created two blob containers under different storage accounts at different Azure regions.

            So that, if application find issues while WRITING to primary blob container, application will perform circuit-breaker logic and if issue persists even after threshold number of attempts, application will start WRITING to stand-by blob storage account which is located in different Azure location & this architecture works fine.

            Code used to switch from primary to secondary:

            ...

            ANSWER

            Answered 2021-Mar-12 at 07:20

            First, as you may know, there is no official docker image of Azcopy available. The github issue mentions it.

            And yes, you can use azure function to do it(about ADF, not sure, but asked some guys, they say it's not easy to do that), but it may a little difficult.

            The easier solution is to use azure web job and azcopy together. Just specify the webjob as schedule when creating it in azure portal. Azure webjob supports many file types like .ps1(powershell), .cmd, .py etc. So it's very easy to use one of your favorites to create it.

            Here, I will create a .ps1(powershell) file, then upload it to azure webjob to execute the sync job on scheduled time.

            Step 1: create a .ps1 file. The name of the file must be run.ps1. Then use the code below in the run.ps1 file(please use your own source storage and destination storage in the code):

            Source https://stackoverflow.com/questions/66549454

            QUESTION

            how to use/implement a custom nodejs Circuit Breaker based on the number of requests?
            Asked 2021-Jan-04 at 00:24

            I'm trying to figure out what is the best wait to implement a circuit breaker based of the number of requests been served in a Typescript/express application instead of fails percentage.

            Since the application is meant to be executed by large number of users and under a heavy load, I'm trying to customize the response code in order to trigger a horizontal scaling event with k8s/istio.

            The first thing I want to start with is to get is the number of requests in nodejs eventloop event if there is some async work in progress, because a big part of my request are executed asynchronously using async/await.

            BTW:
            I have seen these Libs

            Is there any good Idea/path I can start with in order to make this possible ?

            ...

            ANSWER

            Answered 2021-Jan-04 at 00:24

            I can't tell for sure from your question, but if what you're trying to do is to just keep track of how many requests are in progress and then do something in particular if that number exceeds a particular value, then you can use this middleware:

            Source https://stackoverflow.com/questions/65554494

            QUESTION

            Polly Circuit Breaker handled and unhandled exceptions
            Asked 2020-Nov-25 at 12:46

            I want to use Polly to implement a Circuit Breaker pattern.

            In the docs, there is a description of the Half Open state, and there it says:

            • If a handled exception is received, that exception is rethrown, and the circuit transitions immediately back to open, and remains open again for the configured timespan.
            • If an unhandled exception is received, the circuit remains in half-open.

            I'm not sure I understand the difference here between handled and unhandled exception. We are describing a case where an action is run by the policy and is throwing an exception.

            When they say the exception is handled, where do they mean it's being handled? because as we said, the action threw it so doesn't it mean it's unhandled?

            It makes me not understand completely when the half open state remains half open and when does it transition to open.

            ...

            ANSWER

            Answered 2020-Nov-25 at 12:46

            When you define a Circuit Breaker policy then you can define what sort of exception(s) should be considered by the CB implementation. In other words you can list those exceptions that should be treated as failed execution and should be counted into the successive failure count.

            You can define the list of exceptions with the combination of Handle and Or method calls.

            Let's scrutinize this concept via a simple example:

            Source https://stackoverflow.com/questions/64984030

            QUESTION

            Method not found: Akka.Pattern.CircuitBreaker.Create
            Asked 2020-Nov-11 at 23:49

            I get above error when I'm trying to create a persisting actor with SQL server persistence.

            EDIT: what's weird when I clone repositories akka and akka persistence sql server and attach then instead using nuget packages is working as expected. I'm using followinf versions: "Akka" Version="1.4.11" "Akka.Persistence.SqlServer" Version="1.4.10"

            ...

            ANSWER

            Answered 2020-Nov-11 at 23:49

            You ran into this issue, which was the result of us changing some APIs inside the CircuitBreaker as part of Akka.NET v1.4.11: https://github.com/akkadotnet/Akka.Persistence.SqlServer/issues/177

            We just pushed Akka.Persistence.SqlServer 1.4.11 a couple of minutes ago: https://github.com/akkadotnet/Akka.Persistence.SqlServer/releases/tag/1.4.11 - upgrading to this version should resolve your issue.

            Source https://stackoverflow.com/questions/64790477

            QUESTION

            Elasticsearch unassigned shards CircuitBreakingException[[parent] Data too large
            Asked 2020-Oct-31 at 01:00

            I got alert stating elasticsearch has 2 unassigned shards. I made below api calls to gather more details.

            ...

            ANSWER

            Answered 2020-Oct-31 at 01:00

            two things here, shard allocation exception and circuit breaker exception(nested exception as it looks).

            Please use the below command in your cluster to re-trigger the allocation as previous all retry was failed and the same is suggested in your exception message if you carefully notice. more info on below command is on this related Github issue comment.

            curl -XPOST ':9200/_cluster/reroute?retry_failed

            If still, it doesn't work, then you have to fix the parent circuit breaker exception, you should use the http://localhost:9200/_nodes/stats API to know the exact heap of your ES nodes, and accordingly increase it.

            Source https://stackoverflow.com/questions/64606301

            QUESTION

            What's the purpose of applying the Bulkhead pattern on a non-blocking application?
            Asked 2020-Oct-23 at 07:58

            My understanding of the Bulkhead pattern is that it's a way of isolating thread pools. Hence, interactions with different services use different thread pools: if the same thread pool is shared, one service timing out constantly might exhaust the entire thread pool, taking down the communication with the other (healthy) services. By using different ones, the impact is reduced.

            Given my understanding, I don't see any reason to apply this pattern to non-blocking applications as threads don't get blocked and, therefore, thread pools wouldn't get exhausted either way.

            I would appreciate if someone could clarify this point in case I'm missing something.

            EDIT (explain why it's not a duplicate):

            There's another (more generic) question asking about why using Circuit-Breaker and Bulkhead patterns with Reactor. The question was answered in a very generic way, explaining why all Resilience4J decorators are relevant when working with Reactor.

            My question, on the other hand, is particular to the Bulkhead pattern, as I don't understand its benefits on scenarios where threads don't get blocked.

            ...

            ANSWER

            Answered 2020-Oct-23 at 07:58

            The Bulkhead pattern is not only about isolating thread pools.

            Think of Little's law: L = λ * W

            Where:

            L – the average number of concurrent tasks in a queuing system

            λ – the average number of tasks arriving at a queuing system per unit of time

            W – the average service time a tasks spends in a queuing system

            The Bulkhead pattern is more about controlling L in order to prevent resource exhaustion. This can be done by using:

            • bounded queues + thread pools
            • semaphores

            Even non-blocking applications require resources per concurrent task which you might want to restrict. Semaphores could help to restrict the number of concurrent tasks.

            The RateLimiter pattern is about controlling λ and the TimeLimiter about controlling the maximum time a tasks is allowed to spend.

            An adaptive Bulkhead can even replace RateLimiters. Have a look at this awesome talk "Stop Rate Limiting! Capacity Management Done Right" by Jon Moore"

            We are currently developing an AdaptiveBulkhead in Resilience4j which adapts the concurrency limit of tasks dynamically. The implementation is comparable to TCP Congestion Control algorithms which are using an additive increase/multiplicative decrease (AIMD) scheme to dynamically adapt a congestion window. But the AdaptiveBulkhead is of course protocol-agnostic.

            Source https://stackoverflow.com/questions/64467344

            QUESTION

            Cannot connect to postgresql container using npm pg in a docker-compose scenario
            Asked 2020-Oct-02 at 17:20

            I am using npm pg ("pg": "^7.18.2", "pg-native": "^3.0.0" in my package.json), at which I am new, to connect my newbie node app to a postgresql database. I use docker-compose to start up everything using this configuration:

            ...

            ANSWER

            Answered 2020-Oct-02 at 17:20

            Finally having some time to go further this issue. I uninstall the two pg modules in my fibserver application and install pg again provides me a new version of npm pg module (8.3.3) without having the native part which I probably installed by mistake. Single javascript pg library does the job.

            Source https://stackoverflow.com/questions/63968120

            QUESTION

            Any/All python short-circuit: Why doesn't the following work?
            Asked 2020-Sep-27 at 18:54

            ANSWER

            Answered 2020-Jul-20 at 03:10

            Yes, short circuting happens in python

            Source https://stackoverflow.com/questions/62987814

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install circuit-b

            You can install using 'npm i circuit-b' or download it from GitHub, npm.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/trygve-lie/circuit-b.git

          • CLI

            gh repo clone trygve-lie/circuit-b

          • sshUrl

            git@github.com:trygve-lie/circuit-b.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link