SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Finagle - An Intro to RPC &
Async programming in JVM
Prasanna Kumar.S
prasanna.sathyanarayanan@csscorp.com
Twitter @prasonscala
Agenda
Why RPC & Async programming is Interesting ?
Lets know about "Future" & "Promise "
Finagle !!!! - Writing Protocol Handlers
Code - Lets get in to Action
Use Cases - Where could I use Finagle
Q&A
Why RPC & Async
programming ?
I know my infrastructure
I wanna provide an platform
Isolated computation with callable API's
Don't call me let me call u !!!
RPC + Async gives steroids for your server apps
Lets know about
Future
The fundmental abstraction of Async Programming (Fingale as
well :-) )
A Future is computation which has not yet
performed, i.e it is supposed to happen !!!
Finagle
Writing Protocol Handlers
Client and Server are just service
Define Server / Client in terms of service
Exposing a Service - (Server
Side)
// implement a service
val service = new Service[HttpRequest, HttpResponse] {
def apply(req: HttpRequest) = {
Future(new DefaultHttpResponse(HttpVersion.HTTP_1_1,
HttpResponseStatus.OK))
}
}
// configure the service
ServerBuilder().codec(Http()).bindTo(new InetSocketAddress(10000)).na
me("chutti-server").build(service)
Consuming with Client
val client = ClientBuilder().codec(Http()).hosts("10.10.27.14:10000")
.hostConnectionLimit(1).build()
val req = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
HttpMethod.GET, "/")
val fut = client(req)
fut onSuccess (msg => {
println(msg)
})
Putting it all
object ChuttiServer {
private lazy val globalResponse = (req: HttpRequest) => {
val resp = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResp
onseStatus.OK)
val htmlRes = "welcome finagle session !!!!".getBytes()
resp.setContent(ChannelBuffers.copiedBuffer(htmlRes))
Future.value(resp)
}
def start(): Unit = {
// implement a service
val service = new Service[HttpRequest, HttpResponse] {
def apply(req: HttpRequest) = {
req.getUri() match {
case "/" => globalResponse(req)
case _ => Future(new DefaultHttpResponse(HttpVersion.HTTP_1
_1, HttpResponseStatus.NOT_FOUND))
} } }
val fil = new ChuttiServerFilter[HttpRequest, HttpResponse](Durat
ion.fromMilliseconds(100), new JavaTimer)
val svc = fil andThen fil andThen service
// configure the service
ServerBuilder().codec(Http()).bindTo(new InetSocketAddress(10000)
).name("localhost").build(svc)
}
}
// Filter definition
class ChuttiServerFilter[HttpRequest, HttpResponse](timeout: Duration
, timer: Timer)
extends Filter[HttpRequest, HttpResponse, HttpRequest, HttpResponse]
{
def apply(request: HttpRequest, service: Service[HttpRequest, HttpR
esponse]): Future[HttpResponse] = {
println("req passed thru")
service(request)
}
}
Putting it all (Contd.)
object ChuttiClient {
def main(args: Array[String]) {
val client = ClientBuilder().codec(Http()).
hosts("10.10.27.14:10000").hostConnectionLimit(1).build()
val req = new DefaultHttpRequest(
HttpVersion.HTTP_1_1, HttpMethod.GET, "/")
val fut = client(req)
fut onSuccess (msg => {
println(msg)
})
}
}
Use Cases - Where could I use
Finagle
Q&A
The END
Thanks
Reveal.js
HTML5 CSS3
Sublime Text Editor

Weitere ähnliche Inhalte

Was ist angesagt?

jChaart - Web Dashboard Framework
jChaart - Web Dashboard FrameworkjChaart - Web Dashboard Framework
jChaart - Web Dashboard Framework
oazabir
 

Was ist angesagt? (20)

Orbiter and how to extend Docker Swarm
Orbiter and how to extend Docker SwarmOrbiter and how to extend Docker Swarm
Orbiter and how to extend Docker Swarm
 
Fast food for fast times
Fast food for fast timesFast food for fast times
Fast food for fast times
 
Serverless Ballerina
Serverless BallerinaServerless Ballerina
Serverless Ballerina
 
From Web Developer to Hardware Developer
From Web Developer to Hardware DeveloperFrom Web Developer to Hardware Developer
From Web Developer to Hardware Developer
 
Javascript internals
Javascript internalsJavascript internals
Javascript internals
 
Asynchronous development in JavaScript
Asynchronous development  in JavaScriptAsynchronous development  in JavaScript
Asynchronous development in JavaScript
 
Javascript async / await Frontend-IL
Javascript async / await Frontend-ILJavascript async / await Frontend-IL
Javascript async / await Frontend-IL
 
TekS Short Git Overview
TekS Short Git OverviewTekS Short Git Overview
TekS Short Git Overview
 
Ansible Israel Kickoff Meetup
Ansible Israel Kickoff MeetupAnsible Israel Kickoff Meetup
Ansible Israel Kickoff Meetup
 
Wrapping java in awesomeness aka condensator
Wrapping java in awesomeness aka condensatorWrapping java in awesomeness aka condensator
Wrapping java in awesomeness aka condensator
 
Reactive Angular 2
Reactive Angular 2Reactive Angular 2
Reactive Angular 2
 
Why a new CPAN client cpm is fast
Why a new CPAN client cpm is fastWhy a new CPAN client cpm is fast
Why a new CPAN client cpm is fast
 
Microservices using Node.js and RabbitMQ
Microservices using Node.js and RabbitMQMicroservices using Node.js and RabbitMQ
Microservices using Node.js and RabbitMQ
 
Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0
 
Asynchronní programování
Asynchronní programováníAsynchronní programování
Asynchronní programování
 
Intro to MQ
Intro to MQIntro to MQ
Intro to MQ
 
Server architecture
Server architectureServer architecture
Server architecture
 
jChaart - Web Dashboard Framework
jChaart - Web Dashboard FrameworkjChaart - Web Dashboard Framework
jChaart - Web Dashboard Framework
 
Everything ruby
Everything rubyEverything ruby
Everything ruby
 
DJUGL - Django and AWS Lambda
DJUGL - Django and AWS LambdaDJUGL - Django and AWS Lambda
DJUGL - Django and AWS Lambda
 

Andere mochten auch (7)

Rpc原理与实现
Rpc原理与实现Rpc原理与实现
Rpc原理与实现
 
US DTV Transition
US DTV TransitionUS DTV Transition
US DTV Transition
 
Make it fast for everyone - performance and middleware design
Make it fast for everyone - performance and middleware designMake it fast for everyone - performance and middleware design
Make it fast for everyone - performance and middleware design
 
Serialization and performance in Java
Serialization and performance in JavaSerialization and performance in Java
Serialization and performance in Java
 
Modern Distributed Messaging and RPC
Modern Distributed Messaging and RPCModern Distributed Messaging and RPC
Modern Distributed Messaging and RPC
 
High Performance RPC with Finagle
High Performance RPC with FinagleHigh Performance RPC with Finagle
High Performance RPC with Finagle
 
Netty 4-based RPC System Development
Netty 4-based RPC System DevelopmentNetty 4-based RPC System Development
Netty 4-based RPC System Development
 

Ähnlich wie Finagle - an intro to rpc & a sync programming in jvm

Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"
Fwdays
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
Hiroshi Nakamura
 

Ähnlich wie Finagle - an intro to rpc & a sync programming in jvm (20)

Sharding and Load Balancing in Scala - Twitter's Finagle
Sharding and Load Balancing in Scala - Twitter's FinagleSharding and Load Balancing in Scala - Twitter's Finagle
Sharding and Load Balancing in Scala - Twitter's Finagle
 
Fast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCFast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPC
 
Server Side Swift: Vapor
Server Side Swift: VaporServer Side Swift: Vapor
Server Side Swift: Vapor
 
Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...
Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...
Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...
 
Intro to Node
Intro to NodeIntro to Node
Intro to Node
 
2 Asp Dot Net Ajax Extensions
2 Asp Dot Net Ajax Extensions2 Asp Dot Net Ajax Extensions
2 Asp Dot Net Ajax Extensions
 
gRPC in Go
gRPC in GogRPC in Go
gRPC in Go
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015
 
[HKOSCon 2020] Build an api service using ktor rapidly
[HKOSCon 2020] Build an api service using ktor rapidly[HKOSCon 2020] Build an api service using ktor rapidly
[HKOSCon 2020] Build an api service using ktor rapidly
 
SignalR
SignalRSignalR
SignalR
 
Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"
 
Better Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web ServicesBetter Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web Services
 
Job Queue in Golang
Job Queue in GolangJob Queue in Golang
Job Queue in Golang
 
Tamir Dresher - What’s new in ASP.NET Core 6
Tamir Dresher - What’s new in ASP.NET Core 6Tamir Dresher - What’s new in ASP.NET Core 6
Tamir Dresher - What’s new in ASP.NET Core 6
 
Networked APIs with swift
Networked APIs with swiftNetworked APIs with swift
Networked APIs with swift
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
 
Workshop: Async and Parallel in C#
Workshop: Async and Parallel in C#Workshop: Async and Parallel in C#
Workshop: Async and Parallel in C#
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
 
Async programming on NET
Async programming on NETAsync programming on NET
Async programming on NET
 

Mehr von PrasannaKumar Sathyanarayanan (10)

Akka introtalk HyScala DEC 2016
Akka introtalk HyScala DEC 2016Akka introtalk HyScala DEC 2016
Akka introtalk HyScala DEC 2016
 
Akka fsm presentation
Akka fsm presentationAkka fsm presentation
Akka fsm presentation
 
Cps (continuation passing style) in scala
Cps (continuation passing style) in scalaCps (continuation passing style) in scala
Cps (continuation passing style) in scala
 
Introduction to akka chense
Introduction to akka   chenseIntroduction to akka   chense
Introduction to akka chense
 
Websocket,JSON in JEE7
Websocket,JSON in JEE7Websocket,JSON in JEE7
Websocket,JSON in JEE7
 
Scala Introduction with play - for my CSS nerds
Scala Introduction with play - for my CSS nerdsScala Introduction with play - for my CSS nerds
Scala Introduction with play - for my CSS nerds
 
CDI in JEE6
CDI in JEE6CDI in JEE6
CDI in JEE6
 
Ejb3.1
Ejb3.1Ejb3.1
Ejb3.1
 
Producer consumerproblem
Producer consumerproblemProducer consumerproblem
Producer consumerproblem
 
Scala presentationjune112011
Scala presentationjune112011Scala presentationjune112011
Scala presentationjune112011
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Finagle - an intro to rpc & a sync programming in jvm

  • 1. Finagle - An Intro to RPC & Async programming in JVM Prasanna Kumar.S prasanna.sathyanarayanan@csscorp.com Twitter @prasonscala
  • 2. Agenda Why RPC & Async programming is Interesting ? Lets know about "Future" & "Promise " Finagle !!!! - Writing Protocol Handlers Code - Lets get in to Action Use Cases - Where could I use Finagle Q&A
  • 3. Why RPC & Async programming ? I know my infrastructure I wanna provide an platform Isolated computation with callable API's Don't call me let me call u !!! RPC + Async gives steroids for your server apps
  • 4. Lets know about Future The fundmental abstraction of Async Programming (Fingale as well :-) ) A Future is computation which has not yet performed, i.e it is supposed to happen !!!
  • 5. Finagle Writing Protocol Handlers Client and Server are just service Define Server / Client in terms of service
  • 6. Exposing a Service - (Server Side) // implement a service val service = new Service[HttpRequest, HttpResponse] { def apply(req: HttpRequest) = { Future(new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK)) } } // configure the service ServerBuilder().codec(Http()).bindTo(new InetSocketAddress(10000)).na me("chutti-server").build(service)
  • 7. Consuming with Client val client = ClientBuilder().codec(Http()).hosts("10.10.27.14:10000") .hostConnectionLimit(1).build() val req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/") val fut = client(req) fut onSuccess (msg => { println(msg) })
  • 8. Putting it all object ChuttiServer { private lazy val globalResponse = (req: HttpRequest) => { val resp = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResp onseStatus.OK) val htmlRes = "welcome finagle session !!!!".getBytes() resp.setContent(ChannelBuffers.copiedBuffer(htmlRes)) Future.value(resp) } def start(): Unit = { // implement a service val service = new Service[HttpRequest, HttpResponse] { def apply(req: HttpRequest) = { req.getUri() match { case "/" => globalResponse(req) case _ => Future(new DefaultHttpResponse(HttpVersion.HTTP_1 _1, HttpResponseStatus.NOT_FOUND)) } } } val fil = new ChuttiServerFilter[HttpRequest, HttpResponse](Durat ion.fromMilliseconds(100), new JavaTimer) val svc = fil andThen fil andThen service // configure the service ServerBuilder().codec(Http()).bindTo(new InetSocketAddress(10000) ).name("localhost").build(svc) } } // Filter definition class ChuttiServerFilter[HttpRequest, HttpResponse](timeout: Duration , timer: Timer) extends Filter[HttpRequest, HttpResponse, HttpRequest, HttpResponse]
  • 9. { def apply(request: HttpRequest, service: Service[HttpRequest, HttpR esponse]): Future[HttpResponse] = { println("req passed thru") service(request) } }
  • 10. Putting it all (Contd.) object ChuttiClient { def main(args: Array[String]) { val client = ClientBuilder().codec(Http()). hosts("10.10.27.14:10000").hostConnectionLimit(1).build() val req = new DefaultHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.GET, "/") val fut = client(req) fut onSuccess (msg => { println(msg) }) } }
  • 11. Use Cases - Where could I use Finagle
  • 12. Q&A