Akka-gRPC,Features of Akka-gRPC

Akka gRPC provides support for building streaming gRPC servers and clients on top of Akka Streams and Akka Http.

Features of Akka-gRPC

  1. A generator, that starts from a protobuf service definitions, for:
  2. Model classes
  3. The service API as a Scala trait using Akka Stream Sources
  4. On the server side code to create an Akka HTTP route based on your implementation of the service
  5. On the client side, a client for the service
  6. gRPC Runtime implementation that uses
  • Akka Http/2 support or the server side and
  • grpc-netty-shaded for the client side.

Steps for generated Code

  1. Define the protobuf file under src/main/protobuf folder . If we define file other than src main/protobuf folder the you we have to provide explicit path for .protobuf file under tag.
  2. Compile the .proto file
  3. Setup the server so that client send request to server
  4. Provide the implementation for generated code on server side
  5. Provide the implementation for generated code on client side
  6. Start the server for maven project
mvn compile dependency:properties exec:exec@server

7. Start the client for maven project

mvn compile dependency:properties exec:exec@client

Define Protobuf file

syntax = "proto3";

option java_multiple_files = true;
option java_package = "com.knoldus.helloworld";
option java_outer_classname = "HelloWorldKnoldus";

// The greeting service definition.
service GreeterService {
    // Sends a greeting
    rpc SayHello (HelloRequest) returns (HelloReply) {}
}
message HelloRequest {
    string name = 1;
}
message HelloReply {
    string message = 1;
}

After compiling .proto file , the code will be generated

Set-up Server

First, the GreeterServer main class creates an akka.actor.ActorSystem, a container in which Actors, Akka Streams and Akka HTTP run. Next, it defines a function from HttpRequest to Future[HttpResponse] using the GreeterServiceImpl. This function handles gRPC requests in the HTTP/2 with TLS server that is bound to port 8080 in this example.

#akka #akka-http #akka-streams #grpc #scala

What is GEEK

Buddha Community

Akka-gRPC,Features of Akka-gRPC

Akka-gRPC,Features of Akka-gRPC

Akka gRPC provides support for building streaming gRPC servers and clients on top of Akka Streams and Akka Http.

Features of Akka-gRPC

  1. A generator, that starts from a protobuf service definitions, for:
  2. Model classes
  3. The service API as a Scala trait using Akka Stream Sources
  4. On the server side code to create an Akka HTTP route based on your implementation of the service
  5. On the client side, a client for the service
  6. gRPC Runtime implementation that uses
  • Akka Http/2 support or the server side and
  • grpc-netty-shaded for the client side.

Steps for generated Code

  1. Define the protobuf file under src/main/protobuf folder . If we define file other than src main/protobuf folder the you we have to provide explicit path for .protobuf file under tag.
  2. Compile the .proto file
  3. Setup the server so that client send request to server
  4. Provide the implementation for generated code on server side
  5. Provide the implementation for generated code on client side
  6. Start the server for maven project
mvn compile dependency:properties exec:exec@server

7. Start the client for maven project

mvn compile dependency:properties exec:exec@client

Define Protobuf file

syntax = "proto3";

option java_multiple_files = true;
option java_package = "com.knoldus.helloworld";
option java_outer_classname = "HelloWorldKnoldus";

// The greeting service definition.
service GreeterService {
    // Sends a greeting
    rpc SayHello (HelloRequest) returns (HelloReply) {}
}
message HelloRequest {
    string name = 1;
}
message HelloReply {
    string message = 1;
}

After compiling .proto file , the code will be generated

Set-up Server

First, the GreeterServer main class creates an akka.actor.ActorSystem, a container in which Actors, Akka Streams and Akka HTTP run. Next, it defines a function from HttpRequest to Future[HttpResponse] using the GreeterServiceImpl. This function handles gRPC requests in the HTTP/2 with TLS server that is bound to port 8080 in this example.

#akka #akka-http #akka-streams #grpc #scala

Akka-Streams: All About Graphs!

Graphs
Till now we know how to create a linear pipeline/linear graph. But in real life scenario we generally don’t have linear graphs to implement. The graphs can be complex. In Akka Streams computation graphs are written in a more graph-resembling DSL. It aims to make translating graph drawings (e.g. from notes taken from design discussions, or illustrations in protocol specifications) to and from code simpler.

Graphs are used to perform fan-in and fan-out operations. You can consider graph operations as junctions(multiple flows connected at a single point).

Fan-in : It takes multiple inputs and produces a single output.
Fan-out : It produces multiple outputs by taking a single input.

#akka #akka-streams #big data and fast data #scala #akka-streaming #graphs #graphs-in-akka #partialgraphs

Roberta  Ward

Roberta Ward

1595344320

Wondering how to upgrade your skills in the pandemic? Here's a simple way you can do it.

Corona Virus Pandemic has brought the world to a standstill.

Countries are on a major lockdown. Schools, colleges, theatres, gym, clubs, and all other public places are shut down, the country’s economy is suffering, human health is on stake, people are losing their jobs and nobody knows how worse it can get.

Since most of the places are on lockdown, and you are working from home or have enough time to nourish your skills, then you should use this time wisely! We always complain that we want some ‘time’ to learn and upgrade our knowledge but don’t get it due to our ‘busy schedules’. So, now is the time to make a ‘list of skills’ and learn and upgrade your skills at home!

And for the technology-loving people like us, Knoldus Techhub has already helped us a lot in doing it in a short span of time!

If you are still not aware of it, don’t worry as Georgia Byng has well said,

“No time is better than the present”

– Georgia Byng, a British children’s writer, illustrator, actress and film producer.

No matter if you are a developer (be it front-end or back-end) or a data scientisttester, or a DevOps person, or, a learner who has a keen interest in technology, Knoldus Techhub has brought it all for you under one common roof.

From technologies like Scala, spark, elastic-search to angular, go, machine learning, it has a total of 20 technologies with some recently added ones i.e. DAML, test automation, snowflake, and ionic.

How to upgrade your skills?

Every technology in Tech-hub has n number of templates. Once you click on any specific technology you’ll be able to see all the templates of that technology. Since these templates are downloadable, you need to provide your email to get the template downloadable link in your mail.

These templates helps you learn the practical implementation of a topic with so much of ease. Using these templates you can learn and kick-start your development in no time.

Apart from your learning, there are some out of the box templates, that can help provide the solution to your business problem that has all the basic dependencies/ implementations already plugged in. Tech hub names these templates as xlr8rs (pronounced as accelerators).

xlr8rs make your development real fast by just adding your core business logic to the template.

If you are looking for a template that’s not available, you can also request a template may be for learning or requesting for a solution to your business problem and tech-hub will connect with you to provide you the solution. Isn’t this helpful 🙂

Confused with which technology to start with?

To keep you updated, the Knoldus tech hub provides you with the information on the most trending technology and the most downloaded templates at present. This you’ll be informed and learn the one that’s most trending.

Since we believe:

“There’s always a scope of improvement“

If you still feel like it isn’t helping you in learning and development, you can provide your feedback in the feedback section in the bottom right corner of the website.

#ai #akka #akka-http #akka-streams #amazon ec2 #angular 6 #angular 9 #angular material #apache flink #apache kafka #apache spark #api testing #artificial intelligence #aws #aws services #big data and fast data #blockchain #css #daml #devops #elasticsearch #flink #functional programming #future #grpc #html #hybrid application development #ionic framework #java #java11 #kubernetes #lagom #microservices #ml # ai and data engineering #mlflow #mlops #mobile development #mongodb #non-blocking #nosql #play #play 2.4.x #play framework #python #react #reactive application #reactive architecture #reactive programming #rust #scala #scalatest #slick #software #spark #spring boot #sql #streaming #tech blogs #testing #user interface (ui) #web #web application #web designing #angular #coronavirus #daml #development #devops #elasticsearch #golang #ionic #java #kafka #knoldus #lagom #learn #machine learning #ml #pandemic #play framework #scala #skills #snowflake #spark streaming #techhub #technology #test automation #time management #upgrade

Akka Cluster in use (Part 3): Setup a Local Akka Cluster

Hello friends, I hope you all are safe in COVID-19 pandemic and learning new tools and tech while staying at home.

In our last blog post on Akka Cluster, we learnt about the configurations we need in order to form an Akka Cluster. But we didn’t saw it in action. Hence in this blog post, we will see one in action.

Step 1: Download the Sample

To start with forming an Akka Cluster, download the Reactive Banking sample from Techhub.

It is a simple Akka application for managing customer credibility money as part of the Reactive Banking system. It is built using Akka HTTP and Akka Cluster Sharding. It includes a credibility program that allows users to accumulate money each time they add money in their account. Once they have accumulated enough money they can debit that money. This is a skeleton of the Credibility Service with a minimal feature set. It allows us to credit money to an account and debit money from the account. It also ensures that an account balance never goes below zero (You can’t debit money that you don’t have).

Step 2: Run First Node

Now we are ready to run our first node which has to be the first seed node. Since we are going to run many nodes on one machine we have to use different port. Hence for first node we will use port: 2551

$ sbt "run -Dakka.http.server.default-http-port=8000 -Dakka.remote.artery.canonical.port=2551 -Dakka.management.http.port=8558"

Before we execute this command, let’s first understand it:

  • akka.http.server.default-http-port: It defines the default port to bind HTTP server to when no port was explicitly given.
  • akka.remote.artery.canonical.port: The default remote server port clients should connect to. It’s default value is 25520, we can use 0 if we want a random available port. This port needs to be unique for each actor system on the same machine.
  • akka.management.http.port: The port where the HTTP Server for Http Cluster Management will be bound. The value can be from 0 to 65535.

Now when we understand the configurations provided with the sbt command, let’s run our first node of the Akka Cluster.

In the above image, we can see that since there is only one node of the Akka Cluster running, it will join with itself and it will become the leader.

#akka #akka-http #reactive programming #scala #tech blogs #akka-cluster

Ryan  Schneider

Ryan Schneider

1591916760

gRPC: An Introduction With Scala Compiler

Hola, does your application have a client-server architecture or microservices architecture or distributed architecture? Then, you must be using some kind of protocol for inter-application communication or you want to get started with one. So, Let’s start digging.

#grpc #microservices #scala #tech blogs #grpc frameworks #what is grpc