Lagom Circuit Breaker: What, Why and How?

Knoldus Blogs

When our service depends on a third party service’s end point for response, it is possible that due to various reasons, that may vary from bad connection to an internal server error from the third party, our own service fails. A circuit breaker is employed to prevent cascading failures in our services if such scenarios were to occur. And if you are here, you are probably looking forward to customise the circuit breaker within your own service. So, shall we?

First of, when working with lagom in java, the circuit breaker functionality is on even if you don’t do anything about it. But it is always better to customise things to suit our own needs, right? So let’s first get the concept of circuit breaker clear in our head. A circuit breaker can have one of the following three states at an instant:

  1. Closed,
  2. Open, and
  3. Half-Open

Also, there are…

View original post 1,021 more words

Posted in Uncategorized | Leave a comment

What to do for overriding the PureConfig behavior in Scala ?

Knoldus Blogs

PureConfig has its own predefined behavior for reading and writing to the configuration files, but sometimes we got the tricky requirement in which we need some specific behavior; for example to read the config.

It is possible to override the behavior of PureConfig for a certain type by implementing another instance of ConfigReader, ConfigWriter or ConfigConvert. So in this blog we will discuss all 3 override types.

1. ConfigReader:
The default behavior of PureConfig for String is to return the string itself in the configuration.
For example, when below configuration will be read by PureConfig, it will be read as it is :

Reading configuration:

Output :

This is the default behavior of ConfigReader in which the output is same as it is defined in configuration file.

View original post 147 more words

Posted in Uncategorized | Leave a comment

Deep dive into PureConfig types in Scala

Knoldus Blogs

Folks, I am back with some more exploration on PureConfig. This time we will talk about the types. For types, we have following two things to discuss:

  • New supported types
  • Override behaviour for types
  • In this blog, we will discuss only the first one i.e. New supported types

    New supported types: PureConfig does not support all kind of types. For ex, classes that are not case classes are not supported out-of-the-box

    In order to read an instance of a given type T from a config, PureConfig needs to have in scope in implicit instance of ConfigReader[T] for that type.

    You can see above that Year is not a case class. Therefore, this won’t compile because there’s no ConfigReader instance for Year:

    PureConfig can be extended to support those types. To do so, an instance for the ConfigReader type class must be provided.

    First, define a ConfigReader instance in…

    View original post 80 more words

    Posted in Uncategorized | Leave a comment

    A better way to load configuration of certain types with PureConfig in Scala

    Knoldus Blogs

    Hello Folks, Hope you all are doing good !!!

    In this blog we will discuss about the better way of loading the configuration of certain types. Now a days we use typesafe config for the same purpose. PureConfig also uses typesafe config internally but also provides the better way of doing this.

    PureConfig is not a configuration library, it can be seen as a better front-end for the existing libraries. It uses the Typesafe Config library for loading raw configurations and then uses the raw configurations to do its magic.

    The goal of PureConfig is to create at compile-time the boilerplate necessary to load a configuration of a certain type. In other words, you define what to load and PureConfig provides how to load it.

    To use the PurConfig, we need to add dependency in build.sbt for scala 2.11, 2.12:

    Now define the config in application.conf file :

    You can…

    View original post 99 more words

    Posted in Uncategorized | Leave a comment

    Introduction to Accumulators : Apache Spark

    Knoldus Blogs

    Whats the Problem  : Function like map() , filter() can use variables defined outside them in the driver program but each task running on the cluster gets a new copy of each variable, and updates from these copies are not propagated back to the driver.

    The Solution : Spark provides two type of shared variables.

    1.    Accumulators
    2.    Broadcast variables

    Here we are only interesting in Accumulators . if you wants to read about Broadcast variables then you can refer this Blog

    Accumulators provides a simple syntax for aggregating values from worker nodes back to the driver program. One of the most common use of Accumulator is count events that may help in debugging process.

    Example :-  to understand Accumulators better lets take a example of football.

    Div Date HomeTeam AwayTeam FTHG FTAG FTR
    D1 14/08/15 Bayern Munich Hamburg 5 H
    D1 15/08/15 Augsburg Hertha 1 A

    View original post 337 more words

    Posted in Uncategorized | Leave a comment

    Configure turn server for WebRTC on Amazon EC2

    Knoldus Blogs

    As we all know, WebRTC is used for video communication.
    In video communication, data packets are transferred from one place to another place, therefore a user is able to see other user’s streaming.

    But sometimes, when there are some network securities like firewall, then data packet does not transfer and we do not get proper streaming of another user i.e. we get black screen as other user’s stream.

    So for this solution, we use turn server.

    The TURN Server is a VoIP media traffic NAT traversal server and gateway. It can be used as a general-purpose network traffic TURN server and gateway, too.

    Here, I am going to explain you the steps of installing and configuring turn server on Amazon EC2.

    First of all download these 2 packages :
    libevent-2.0.21-stable.tar.gz (
    turnserver- (

    then run these commands :
    1. To install libevent package
    $ tar xvfz libevent-2.0.21-stable.tar.gz
    $ cd libevent-2.0.21-stable

    View original post 163 more words

    Posted in Uncategorized | Leave a comment

    Neo4j with Scala : User Defined Procedure and APOC

    Knoldus Blogs

    In the last blog Getting Started Neo4j with Scala : An Introduction which got the overwhelming response from Neo4j and Dzone. We discussed about how to use Neo4j with Scala. For recap Blog and the Code. Now we are going to take one step ahead .

    As we know that in the Relational Database, Procedure provide advantages of better performance, scalability, productivity, ease of use and security.

    In the Neo4j we also used APOC and User Defined Procedure which provide same advantages which we get in the Relational Database.

    User Defined Function

    We used user defined procedure in the Relational Database which we store in the database and call from there whenever needed. In Neo4j we also do the same thing. Here we create procedure method with the @Procedure annotation.

    When we annotated with @Procedure, it takes any Cypher Type as parameters and returns Stream of Data…

    View original post 797 more words

    Posted in Uncategorized | Leave a comment