SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
FROM ‘00s TO ‘20s:
FROM RESTful to gRPC
Gianfranco Reppucci
@giefferre Data Engineer
WHAT THIS TALK
IS ABOUT
BEFORE REST
S O A P
Common Object Request
Broker Architecture
Simple Object
Access Protocol
REST: REpresentational State Transfer
REST PRINCIPLES
Extension of the
web resource
concept
Identification of
resources with a
universal syntax
Resource
accessibility via a
universal interface
REST ARCHITECTURAL ELEMENTS
DATA ELEMENTS CONNECTORS COMPONENTS
REPRESENTATIONSURIsRESOURCES
REST CONSTRAINTS
Client - Server Stateless Cacheability
Uniform Interface Layered System Code On Demand
SO, WHAT’S THE
PROBLEM WITH REST?
RELATIONSHIP BETWEEN URIs
AND HTTP VERBS / 1
GET PUT PATCH
POST DELETE
List of URIs (w/other details?) of all
the person items in the database
Replace the entire persons
dataset with a new one
Not generally used
ok...
Add a new person
to the dataset
Delete the entire persons
dataset
https://api.example.com/persons
RELATIONSHIP BETWEEN URIs
AND HTTP VERBS / 2
Retrieve the person matching
the given identifier “123”
Replace the addressed
person with a new one
Update the addressed person
with the given fields
Not generally used
uhm...
Delete the addressed person
from the dataset
https://api.example.com/persons/123
GET PUT PATCH
POST DELETE
RESTful IS EVIL
FULL LIST OF HTTP VERBS
OPTIONS GET POSTHEAD
PUT DELETE CONNECTTRACE
ツ
FULL LIST OF HTTP STATUS CODES / 1
INFORMATIONAL SUCCESS REDIRECTION
100, 101, 102, 103 200, 201, 203, 204,
205, 206, 207, 208,
226
300, 301, 302, 303,
304, 305, 306, 307,
308
FULL LIST OF HTTP STATUS CODES / 1
CLIENT
ERRORS
SERVER
ERRORS
UNOFFICIAL
CODES
400, 401, 402, 403,
404, 405, 406, 407,
408, 409, 410, 411,
412, 413, 414, 415,
416, 417, 418, 421,
422, 423, 424, 426,
428, 429, 431, 451
500, 501, 502, 503,
504, 505, 506, 507,
508, 510, 511
103, 218, 420, 450,
498, 499, 509, 530,
598, many more...
PROBLEMS OF
RESTful APIs
#1
LITTLE AGREEMENT ON WHAT “RESTful” MEANS
#2
REST VOCABULARY IS NOT FULLY SUPPORTED
#3
REST VOCABULARY IS NOT RICH ENOUGH FOR A COMPLETE API
#4
RESTful APIs ARE TIED TO HTTP
H T T P
MOVING FORWARD
JSON - RPC
STATELESS LIGHTWEIGHT TRANSPORT
AGNOSTIC
USES JSON AS
DATA FORMAT
SUPPORTS
NOTIFICATION REQUEST
JSON - RPC : REQUEST
{
"jsonrpc": "2.0",
"method": "DemoRPCService.CreatePerson",
"params": {
"name": "Gianfranco",
"surname": "Reppucci",
"age": 36
},
"id": 1234567
}
JSON - RESPONSE
{
"jsonrpc": "2.0",
"result": {
"id": "bcjsuge8t5ekk4rj6b4g",
"name": "Gianfranco",
"surname": "Reppucci",
"age": 36
},
"id": 1234567
}
JSON - RPC : NOTIFICATION
{
"jsonrpc": "2.0",
"method": "DemoRPCService.CheckForNewPersons"
}
JSON - RPC : ERROR
{
"jsonrpc": "2.0",
"error": {
"code": -32000,
"message": "person: invalid name or surname
given",
"data": null
},
"id": 1234567
}
BATCH REQUESTS
Useful to aggregate
multiple requests
Server is obliged to respond to
every non-Notification request
JSON-RPC ADVANTAGES
Readability Ease of encoding /
decoding
Separation from
transport protocol
JSON-RPC DISADVANTAGES
No binary
encoding
Ease to mess up
method names
github.com/giefferre/jsonrpc-usage-example
MOVING FAST FORWARD
gRPC
Open Source Remote
Procedure Call protocol
Developed initially
at Google
Uses HTTP/2
for transport
Protocol Buffers as
Interface Description Language
gRPC: PRINCIPLES
Services, not Objects
Messages, not
References
Built-in support for 10
languages across multiple
environments
Blocking /
Non Blocking
(Bidirectional)
Streaming
Cancellation &
Timeout
Flow
Control
Standardized
Status Codes
DEFINITION OF A SAMPLE SERVICE / 1
message Person {
string id = 1; // Unique ID for this person.
string name = 2;
string surname = 3;
uint32 age = 4;
}
DEFINITION OF A SAMPLE SERVICE / 2
message CreatePersonArgs {
string name = 1;
string surname = 2;
uint32 age = 3;
}
message ReadPersonArgs {
string id = 1;
}
DEFINITION OF A SAMPLE SERVICE / 3
service DemoRPCService {
rpc CreatePerson (CreatePersonArgs) returns (Person) {}
rpc ReadPerson (ReadPersonArgs) returns (Person) {}
}
WRITING A SERVER IN GO / 1
type demoRPCServer struct {
...
}
func (s *demoRPCServer) CreatePerson
(ctx context.Context, args *CreatePersonArgs) (*Person, error) {
...
}
func (s *demoRPCServer) ReadPerson
(ctx context.Context, args *ReadPersonArgs) (*Person, error) {
...
}
WRITING A SERVER IN GO / 2
func main() {
listener, err := net.Listen("tcp", ":1234")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
grpcServer := grpc.NewServer()
RegisterDemoRPCServiceServer(grpcServer, &demoRPCServer{})
grpcServer.Serve(listener)
}
WRITING A CLIENT IN PYTHON
channel = grpc.insecure_channel('localhost:6000')
client = rpcservice.DemoRPCServiceStub(channel)
new_person = client.CreatePerson(
pb.CreatePersonArgs(
name='John',
surname='Doe',
age=36,
)
)
github.com/giefferre/grpc-usage-example
CONCLUSIONS
REST concepts are solid,
RESTful implementations
aren’t
*RPC alternatives
are valid
You can take advantages of
some REST concepts when
developing *RPC services
JSON-RPC and gRPC are
modern and they can be
pretty powerful
JOIN US
THANK YOU
Gianfranco Reppucci
@giefferre Data Engineer

Weitere Àhnliche Inhalte

Ähnlich wie From '00s to '20s: from RESTful to gRPC

Introduction to JSON & AJAX
Introduction to JSON & AJAXIntroduction to JSON & AJAX
Introduction to JSON & AJAXRaveendra R
 
REST to GraphQL migration: Pros, cons and gotchas
REST to GraphQL migration: Pros, cons and gotchasREST to GraphQL migration: Pros, cons and gotchas
REST to GraphQL migration: Pros, cons and gotchasAlexey Ivanov
 
R, HTTP, and APIs, with a preview of TopicWatchr
R, HTTP, and APIs, with a preview of TopicWatchrR, HTTP, and APIs, with a preview of TopicWatchr
R, HTTP, and APIs, with a preview of TopicWatchrPortland R User Group
 
"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)
"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)
"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)Portland R User Group
 
FIWARE Training: JSON-LD and NGSI-LD
FIWARE Training: JSON-LD and NGSI-LDFIWARE Training: JSON-LD and NGSI-LD
FIWARE Training: JSON-LD and NGSI-LDFIWARE
 
GraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learnedGraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learnedMarcinStachniuk
 
Hypermedia APIs and HATEOAS / Wix Engineering
Hypermedia APIs and HATEOAS / Wix EngineeringHypermedia APIs and HATEOAS / Wix Engineering
Hypermedia APIs and HATEOAS / Wix EngineeringVladimir Tsukur
 
Arabidopsis Information Portal, Developer Workshop 2014, Introduction
Arabidopsis Information Portal, Developer Workshop 2014, IntroductionArabidopsis Information Portal, Developer Workshop 2014, Introduction
Arabidopsis Information Portal, Developer Workshop 2014, IntroductionJasonRafeMiller
 
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers ProgramSession 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers ProgramFIWARE
 
Yet another json rpc library (mole rpc)
Yet another json rpc library (mole rpc)Yet another json rpc library (mole rpc)
Yet another json rpc library (mole rpc)Viktor Turskyi
 
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...PROIDEA
 
FIWARE Training: JSON-LD and NGSI-LD
FIWARE Training: JSON-LD and NGSI-LDFIWARE Training: JSON-LD and NGSI-LD
FIWARE Training: JSON-LD and NGSI-LDFIWARE
 
Restful webservices
Restful webservicesRestful webservices
Restful webservicesKong King
 
Synchronize AD and OpenLDAP with LSC
Synchronize AD and OpenLDAP with LSCSynchronize AD and OpenLDAP with LSC
Synchronize AD and OpenLDAP with LSCLDAPCon
 
JSON-LD and NGSI-LD
JSON-LD and NGSI-LDJSON-LD and NGSI-LD
JSON-LD and NGSI-LDFIWARE
 

Ähnlich wie From '00s to '20s: from RESTful to gRPC (20)

Introduction to JSON & AJAX
Introduction to JSON & AJAXIntroduction to JSON & AJAX
Introduction to JSON & AJAX
 
REST to GraphQL migration: Pros, cons and gotchas
REST to GraphQL migration: Pros, cons and gotchasREST to GraphQL migration: Pros, cons and gotchas
REST to GraphQL migration: Pros, cons and gotchas
 
R, HTTP, and APIs, with a preview of TopicWatchr
R, HTTP, and APIs, with a preview of TopicWatchrR, HTTP, and APIs, with a preview of TopicWatchr
R, HTTP, and APIs, with a preview of TopicWatchr
 
"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)
"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)
"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)
 
FIWARE Training: JSON-LD and NGSI-LD
FIWARE Training: JSON-LD and NGSI-LDFIWARE Training: JSON-LD and NGSI-LD
FIWARE Training: JSON-LD and NGSI-LD
 
Life on Clouds: a forensics overview
Life on Clouds: a forensics overviewLife on Clouds: a forensics overview
Life on Clouds: a forensics overview
 
Introduction to Hydra
Introduction to HydraIntroduction to Hydra
Introduction to Hydra
 
GraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learnedGraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learned
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Hypermedia APIs and HATEOAS / Wix Engineering
Hypermedia APIs and HATEOAS / Wix EngineeringHypermedia APIs and HATEOAS / Wix Engineering
Hypermedia APIs and HATEOAS / Wix Engineering
 
JSON and REST
JSON and RESTJSON and REST
JSON and REST
 
Arabidopsis Information Portal, Developer Workshop 2014, Introduction
Arabidopsis Information Portal, Developer Workshop 2014, IntroductionArabidopsis Information Portal, Developer Workshop 2014, Introduction
Arabidopsis Information Portal, Developer Workshop 2014, Introduction
 
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers ProgramSession 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
 
Yet another json rpc library (mole rpc)
Yet another json rpc library (mole rpc)Yet another json rpc library (mole rpc)
Yet another json rpc library (mole rpc)
 
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...
 
FIWARE Training: JSON-LD and NGSI-LD
FIWARE Training: JSON-LD and NGSI-LDFIWARE Training: JSON-LD and NGSI-LD
FIWARE Training: JSON-LD and NGSI-LD
 
126 Golconde
126 Golconde126 Golconde
126 Golconde
 
Restful webservices
Restful webservicesRestful webservices
Restful webservices
 
Synchronize AD and OpenLDAP with LSC
Synchronize AD and OpenLDAP with LSCSynchronize AD and OpenLDAP with LSC
Synchronize AD and OpenLDAP with LSC
 
JSON-LD and NGSI-LD
JSON-LD and NGSI-LDJSON-LD and NGSI-LD
JSON-LD and NGSI-LD
 

KĂŒrzlich hochgeladen

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfWilly Marroquin (WillyDevNET)
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp KrisztiĂĄn
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 

KĂŒrzlich hochgeladen (20)

Abortion Pill Prices Tembisa [(+27832195400*)] đŸ„ Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] đŸ„ Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] đŸ„ Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] đŸ„ Women's Abortion Clinic in T...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Abortion Pills In Pretoria ](+27832195400*)[ đŸ„ Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ đŸ„ Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ đŸ„ Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ đŸ„ Women's Abortion Clinic In Pre...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 

From '00s to '20s: from RESTful to gRPC

  • 1. FROM ‘00s TO ‘20s: FROM RESTful to gRPC Gianfranco Reppucci @giefferre Data Engineer
  • 3. BEFORE REST S O A P Common Object Request Broker Architecture Simple Object Access Protocol
  • 5. REST PRINCIPLES Extension of the web resource concept Identification of resources with a universal syntax Resource accessibility via a universal interface
  • 6. REST ARCHITECTURAL ELEMENTS DATA ELEMENTS CONNECTORS COMPONENTS REPRESENTATIONSURIsRESOURCES
  • 7. REST CONSTRAINTS Client - Server Stateless Cacheability Uniform Interface Layered System Code On Demand
  • 9. RELATIONSHIP BETWEEN URIs AND HTTP VERBS / 1 GET PUT PATCH POST DELETE List of URIs (w/other details?) of all the person items in the database Replace the entire persons dataset with a new one Not generally used ok... Add a new person to the dataset Delete the entire persons dataset https://api.example.com/persons
  • 10. RELATIONSHIP BETWEEN URIs AND HTTP VERBS / 2 Retrieve the person matching the given identifier “123” Replace the addressed person with a new one Update the addressed person with the given fields Not generally used uhm... Delete the addressed person from the dataset https://api.example.com/persons/123 GET PUT PATCH POST DELETE
  • 12. FULL LIST OF HTTP VERBS OPTIONS GET POSTHEAD PUT DELETE CONNECTTRACE
  • 14. FULL LIST OF HTTP STATUS CODES / 1 INFORMATIONAL SUCCESS REDIRECTION 100, 101, 102, 103 200, 201, 203, 204, 205, 206, 207, 208, 226 300, 301, 302, 303, 304, 305, 306, 307, 308
  • 15. FULL LIST OF HTTP STATUS CODES / 1 CLIENT ERRORS SERVER ERRORS UNOFFICIAL CODES 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 421, 422, 423, 424, 426, 428, 429, 431, 451 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511 103, 218, 420, 450, 498, 499, 509, 530, 598, many more...
  • 16.
  • 18. #1 LITTLE AGREEMENT ON WHAT “RESTful” MEANS
  • 19. #2 REST VOCABULARY IS NOT FULLY SUPPORTED
  • 20. #3 REST VOCABULARY IS NOT RICH ENOUGH FOR A COMPLETE API
  • 21. #4 RESTful APIs ARE TIED TO HTTP H T T P
  • 23. JSON - RPC STATELESS LIGHTWEIGHT TRANSPORT AGNOSTIC USES JSON AS DATA FORMAT SUPPORTS NOTIFICATION REQUEST
  • 24. JSON - RPC : REQUEST { "jsonrpc": "2.0", "method": "DemoRPCService.CreatePerson", "params": { "name": "Gianfranco", "surname": "Reppucci", "age": 36 }, "id": 1234567 }
  • 25. JSON - RESPONSE { "jsonrpc": "2.0", "result": { "id": "bcjsuge8t5ekk4rj6b4g", "name": "Gianfranco", "surname": "Reppucci", "age": 36 }, "id": 1234567 }
  • 26. JSON - RPC : NOTIFICATION { "jsonrpc": "2.0", "method": "DemoRPCService.CheckForNewPersons" }
  • 27. JSON - RPC : ERROR { "jsonrpc": "2.0", "error": { "code": -32000, "message": "person: invalid name or surname given", "data": null }, "id": 1234567 }
  • 28. BATCH REQUESTS Useful to aggregate multiple requests Server is obliged to respond to every non-Notification request
  • 29. JSON-RPC ADVANTAGES Readability Ease of encoding / decoding Separation from transport protocol
  • 33. gRPC Open Source Remote Procedure Call protocol Developed initially at Google Uses HTTP/2 for transport Protocol Buffers as Interface Description Language
  • 34. gRPC: PRINCIPLES Services, not Objects Messages, not References Built-in support for 10 languages across multiple environments Blocking / Non Blocking (Bidirectional) Streaming Cancellation & Timeout Flow Control Standardized Status Codes
  • 35. DEFINITION OF A SAMPLE SERVICE / 1 message Person { string id = 1; // Unique ID for this person. string name = 2; string surname = 3; uint32 age = 4; }
  • 36. DEFINITION OF A SAMPLE SERVICE / 2 message CreatePersonArgs { string name = 1; string surname = 2; uint32 age = 3; } message ReadPersonArgs { string id = 1; }
  • 37. DEFINITION OF A SAMPLE SERVICE / 3 service DemoRPCService { rpc CreatePerson (CreatePersonArgs) returns (Person) {} rpc ReadPerson (ReadPersonArgs) returns (Person) {} }
  • 38. WRITING A SERVER IN GO / 1 type demoRPCServer struct { ... } func (s *demoRPCServer) CreatePerson (ctx context.Context, args *CreatePersonArgs) (*Person, error) { ... } func (s *demoRPCServer) ReadPerson (ctx context.Context, args *ReadPersonArgs) (*Person, error) { ... }
  • 39. WRITING A SERVER IN GO / 2 func main() { listener, err := net.Listen("tcp", ":1234") if err != nil { log.Fatalf("failed to listen: %v", err) } grpcServer := grpc.NewServer() RegisterDemoRPCServiceServer(grpcServer, &demoRPCServer{}) grpcServer.Serve(listener) }
  • 40. WRITING A CLIENT IN PYTHON channel = grpc.insecure_channel('localhost:6000') client = rpcservice.DemoRPCServiceStub(channel) new_person = client.CreatePerson( pb.CreatePersonArgs( name='John', surname='Doe', age=36, ) )
  • 42. CONCLUSIONS REST concepts are solid, RESTful implementations aren’t *RPC alternatives are valid You can take advantages of some REST concepts when developing *RPC services JSON-RPC and gRPC are modern and they can be pretty powerful