API
REST gRPC
#ShinjukuLT
@disc99
•
• RESTful API
• gRPC
•
?
• > ThoughtWorks


(O'Reilly)
> In short, the microservice architectural style is
an approach to developing a single application
as a suite of small services, each running in its
own process and communicating with
lightweight mechanisms, often an HTTP
resource API.
=> HTTP API
Microservices @Martin Fowler, @James Lewis
https://martinfowler.com/articles/microservices.html
RESTful API
> RESTful API Web
(API) REST
REST
REST Web API RESTful API


> URL/URI
( )


> HTTP XML HTML
JSON HTTP
e-Words
http://e-words.jp/w/RESTful_API.html
* RESTful API REST API
• Web API
• URL/URI
• : HTTP
• : XML HTML JSON + HTTP
• : :✕
✋API
Q1.
Q. API
1. URL
2.
3. HTTP Header
4.
Q2. API
Q. API HTTP ?
1. POST
2. REST API PUT
3. PATCH
4.
Q3. API
• Q. DB
?
1. DB 500
2.
400+
3. 409
4.
Q4. API
• Q. ?
1.
2.
3.
4.
A.
?
•
>


=>
> 2 2


=>
( )
RESTful
• Web API
=> 

=>
*1
REST
https://togetter.com/li/14062
• REST API
•
•
•
• API
•
• Web ( )
• RESTful Web (O'Reilly)
• Web API: The Good Parts(O'Reilly)
• Microsoft REST API Guidelines
• https://github.com/Microsoft/api-guidelines/blob/master/
Guidelines.md
• Google API Design Guide
• https://cloud.google.com/apis/design/
•
• Google Microsoft Amazon Twitter Facebook
Netflix API
• Dropbox REST AWS API REST
• https://medium.com/@voluntas/http-api-
-7ccaca671d9d
• URL
•
•
•
• or :
•
• Swagger API Blueprint RAML JSON (Hyper)Scheme
•
•
•
• E2E Consumer-Driven
Contracts
• API …
•
•
•
•
( …)
RESTful Web @t_wada
https://www.slideshare.net/t_wada/restful-web-design-review
• REST
• REST
• REST
•
•
• • REST API
* REST API
• • REST API
* REST API
REST API
•
•
• HTTP
• API JSON JavaScript
=> API
REST API
?
Web API
>Web API
REST RPC SOAP
> RPC : 

Remote Procedure Call
> RPC : 

SDK
Web API
>Web API
REST RPC SOAP
> RPC : 

Remote Procedure Call
> RPC : 

SDK
Web API
>Web API
REST RPC SOAP
> RPC : 

Remote Procedure Call
> RPC : 

SDK
gRPC ( )
PRC?
>


>
Wikipedia
https://ja.wikipedia.org/wiki/RPC
RPC
• Java RMI
• XML-RPC
• JSON-RPC
• Apache Thrift
• gRPC
RPC
• Java RMI
• XML-RPC
• JSON-RPC
• Apache Thrift
• gRPC
gRPC
• Google RPC
• Google RPC OSS
• Protocol Buffers *1
•
• HTTP/2
•
• /
Streaming
*1. gRPC Protocol Buffers
Protocol Buffers?
•
• IDL( )
•
•
•
• IDL
•
•
• Google Protocol Buffers
• DB BigData
Protocol Buffers
rebuild.fm#169 @omo
https://rebuild.fm/169/
gRPC
•
• Google
• Square
• Netflix
• CoreOS
• Docker
• Cisco
•
•
• GRPC *1
• AbeamTV
• AbeamTV Microservices *2
•
• Protocol Buffers *3
*1. https://speakerdeck.com/kazegusuri/go-conference-2016-spring
*2. http://www.slideshare.net/RyotaNishio/abematvmicroservices-architecture
*3. http://tayama0324.github.io/slides/20161127-kbkz-tech.html#/
1. (IDL)
2. IDL (
)
3.
4.
5.
gRPC API
• URL
•
•
•
•
•
URL
• IDL
•
•
• repeat map enum
• message stream service nest
•
• *1
• *2
*1. http://www.grpc.io/docs/guides/error.html
*2. ex:Java) http://www.grpc.io/grpc-java/javadoc/io/grpc/Status.html
•
•
•
•
• IDL
•
• protoc-gen-doc: IDL Markdown, HTML *1
• grpc-gateway: gRPC JSON
*2
• polyglot: grpc CLI *3
=> IDL
=>
• *1. https://github.com/estan/protoc-gen-doc
• *2. https://github.com/grpc-ecosystem/grpc-gateway
• *3. https://github.com/grpc-ecosystem
• (Protocol Buffers)
• IDL
•
• /
•
• 1
=> IDL ?
• .proto
• SSL/TLS Google API
•
•
•
•
•
•
=>
•
• https://github.com/grpc/grpc-java/issues/
1469#issuecomment-230852433
Other Pros
•
• XML JSON
•
•
• Protocol Buffers (JSON XML )
•
•
Cons
•
• RESTful API
=> REST ( AbemaTV)
• JSON
=> grpc-gateway polyglot
=>
•
=>
=> grpc-gateway *1
• HTTP/2
=> Kubernetes
*1. https://github.com/grpc/grpc-experiments/issues/159
Note
• gRPC
• gRPC
• DDD + DIP
• API( )
REST API
• (IDL) 

=> 

=> REST


=>
• 

=> 

=>
• Google
• …
=>
=>
•
• HTTP API
• RESTful API
•
•
•
• gRPC
•
•
•
マイクロサービスバックエンドAPIのためのRESTとgRPC
マイクロサービスバックエンドAPIのためのRESTとgRPC

マイクロサービスバックエンドAPIのためのRESTとgRPC