SlideShare a Scribd company logo
1 of 71
TYPES ALL THE WAY DOWN
GENERATING APIS WITH PROTOBUFS AND GRPC
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Watch the video with slide
synchronization on InfoQ.com!
https://www.infoq.com/presentations/
api-pb-grpc
Presented at QCon New York
www.qconnewyork.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
HI!
Christopher Burnett - Lead Core Libraries
Formerly Twitter, VSCO
@twoism
Chris Roche - Core Libraries
Formerly VSCO
@rodaine
CORE LIBRARIES
A little about us…
• HTTP & gRPC Frameworks
• Tooling for Go, Python, and PHP
• Rolling out gRPC within Lyft
AGENDA
• Why choose RPC in the first place?
• Working with legacy systems
• Disrupting workflows, nicely :)
• What we’ve built
EVERY TEN YEARS…
A furious bout of language and protocol design takes place and a new
distributed computing paradigm is announced that is compliant with the
latest programming model.
- A Note On Distributed Computing, Waldo 1994
LOOK FAMILIAR?
• CORBA
• Thrift
• SOAP
• WDDX
• JSON-RPC
• XML-RPC
• Avro
• HyperMedia
• REST
• MessagePack
A LITTLE HISTORY
Like any good story we begin with a PHP
monolith…
• Active decomp efforts
• 100s of Python Microservices
- Flask HTTP/REST
And to keep things interesting…
• gRPC Core and Compositional Services
DEFINING A CORE SERVICE
• Organizational Primitives
- User, Rides, Vehicles
• Zero (Service) Dependencies
- Databases, caches, etc
• Highly Performant
SO, WHY GRPC?
LET’S TALK ABOUT REST
RESTful
RESTish
REST/JSON: S2S COMMUNICATION
POST /api/updateUser HTTP/1.0
Content-Type: application/json
{
"id": 18446744073709551615,
"username": “chris"
}
ALRIGHT, LET’S PAINT THAT SHED…
PUT /api/users HTTP/1.0
Content-Type: application/json
{
"id": 18446744073709551615,
"username": “chris"
}
PUTTING ON ANOTHER COAT…
PUT /api/users/18446744073709551615 HTTP/1.0
Content-Type: application/json
{
"username": “chris"
}
FINISHING TOUCHES…
PUT /api/v1/users/18446744073709551615 HTTP/1.0
Content-Type: application/json
{
"username": “chris"
}
IDLs are pretty great :)
IDLS ARE PRETTY GREAT
• Single Source of Truth
-Primitive definitions
• Code Generation
-APIs, Clients, Servers, Data Models, Docs, Observability
• Extensibility
-Plugins for everything else
IDL SERVICE DEFINITION
package lyft.service.users.v1
service Users {
rpc Update(UpdateRequest) UpdateResponse;
}
message UpdateRequest {
uint64 id = 1;
string name = 2;
}
What about existing
services?
IDL SERVICE DEFINITION — HTTP
package lyft.service.users.v1
service Users {
option (http.http_server_options).isHttpServer = true;
rpc Update(UpdateRequest) returns UpdateResponse {
// Override `path` for legacy URL support
option (http.http_options).path = "/api/v1/users/:id";
option (http.http_options).method = "PUT";
}
}
TYPES ON THE WIRE
• Simplified API I/O
- Structs In, Structs Out
• Safety
- Big wins for dynamic languages
• Transfer Cost
- Improved latencies
ENVOY TOPOLOGY IMAGE
Types on the wire eliminate
an entire class of errors
TypeError: unsupported operand
type(s) for -: 'NoneType' and 'float'
HTTP/2.0
HTTP/2.0
• Full Duplex Streaming
• Binary Transport
• Push
• Header Compression
WHAT’S NOT SO GREAT?
Introducing a new protocol or
language can be highly
traumatic for teams.
“How do I cURL this?”
WHAT CAN MAKE THIS BETTER?
• Incremental Adoption
-Allow teams to opt-in to the new shiny things
• Familiarity
-Tooling that feels welcoming
-Standardized framework patterns
• Roll Forward
-Wire format first, then the protocol and frameworks
How can we make protocol and
infra changes flexible and
transparent?
Service
Mesh
ENVOY TOPOLOGY
Internet
Clients
“Front” Envoy
Legacy PHP
Monolith
Envoy
Go Services
Python Services
Envoy
Envoy
MongoDB /
DynamoDB
Ratelimiting
Stats /
Tracing
Discovery
SIDECAR?
ENVOY: GRPC BRIDGE FILTER
Python HTTP
Envoy
Envoy
HTTP/1
POST /GetUser
200 OK
gRPC
gRPCBridge
ENVOY: JSON PROXY FILTER
Python HTTP
Envoy
Envoy
HTTP/1
POST /GetUser
200 OK
gRPC
JSONFILTER
With Envoy, services and clients
can evolve independently.
*Next Chris
How can we leverage
IDLs beyond the API?
ODIE: IDLS MEET THE DATASTORE
Type-Safe Repository
Driver-Agnostic Client
Expression
Engine
Decorator
Middleware
Database
Driver
IDL-Based
Model
Lifecycle
Events
MongoDB
DynamoDB
Spanner
BoltDB
ODIE: MODELS AS PROTOCOL BUFFERS
message User {
option (odie.mongo).enabled = true;
string id = 1 [(odie.mongo).primary = true,
(odie.type).object_id = true];
string name = 2 [(odie.mongo).name = "username"];
int64 date = 3 [(odie.type).datetime = true];
uint32 vers = 4 [(odie.locking).revision = true];
}
ODIE: MODELS AS PROTOCOL BUFFERS
type UserModel struct {
Id bson.ObjectId `bson:"_id"`
Name string `bson:"username"`
Date time.Time
Vers uint32
}
func (pb *User) ToModel() *UserModel
func (m *UserModel) ToProto() *User
ODIE: TYPE-SAFE REPOSITORIES
type UserRepo interface {
Events() *Events
Get(ctx context.Context, id bson.ObjectId) *GetBuilder
Put(ctx context.Context, m *UserModel) *PutBuilder
Delete(ctx context.Context) *DeleteBuilder
Update(ctx context.Context) *UpdateBuilder
Query(ctx context.Context) *QueryBuilder
}
ODIE: THE PLATONIC IDEAL
• Zero/Empty value ≅ Nil value
- False is semantically the same as null
• Fields are not polymorphic
- All attributes are singularly typed
• Models are rigidly typed
- Legacy data is already mappable
ODIE: THE REALITY
• Zero/Empty value ≅ Nil value
- False is semantically the same as null
• Fields are not polymorphic
- All attributes are singularly typed
• Models are rigidly typed
- Legacy data is already mappable
• true and false …and nil
- Allow proto2 syntax models
• Need to decomp from existing
PHP Doctrine models
- Move source of truth without breaking
legacy code.
• Covariant polymorphic
repeated discriminator maps
- Enough said.
“How do you change the
wheels of a moving train?”
MOVE THE SOURCE OF TRUTH
Entity
UserModel
Schema
Computed
Properties
Behavior
Entity
UserModel
Computed
Properties
Behavior
UserFields
Schema
Codegen
from
the IDL
MOVE THE SOURCE OF TRUTH
Users Service
Envoy
Legacy PHP
Envoy
m.ToProto()
pb.ToModel()
OdieDoctrine
Adapter
Odie
Repo
Legacy
ModelPB / gRPC
Fields
Class
Reduce trauma with
transitional tooling
PYTHON ENVOY-GRPC CLIENTS
// Envoy-gRPC Client
class UsersClient(…):
def get(self, request)
def multiget(self, request)
def update(self, request)
// Official gRPC client
class UsersServiceClient(…):
def get(self, request)
def multiget(self, request)
def update(self, request)
Listen to your customers
“Protobufs are really
hard to use”
OFFICIAL PYTHON MESSAGES
User = _reflection.GeneratedProtocolMessageType('User',
(_message.Message,), dict(
DESCRIPTOR = _USER,
__module__ = 'pb.lyft.user_pb2'
))
_sym_db.RegisterMessage(User)
PYTHON MESSAGE PROXIES
class UserProxy(object):
def __init__(self, base_pb):
self._base = base_pb
@property
def id(self):
return self._base.id
@id.setter
def id(self, value):
self._base.id = value
FURTHER CODE GENERATION
• Go/PHP Envoy-aware clients
• PB over HTTP clients/server
• Observability interceptors
• Ergonomics helpers
• Response caching
• CLI
That’s an awful lot of
codegen…
PROTOC-GEN-STAR (PG*)
Code generation framework

• AST of Lyft primitives
• Simplifies code generation
• Highly testable
Package
File
Service
Method Enum
EnumValue
Message
OneOf
Field
PG*: WALK THE AST
type Visitor interface {
VisitPackage(Package) (v Visitor, err error)
VisitFile(File) (v Visitor, err error)
VisitMessage(Message) (v Visitor, err error)
VisitEnum(Enum) (v Visitor, err error)
VisitEnumValue(EnumValue) (v Visitor, err error)
VisitField(Field) (v Visitor, err error)
VisitOneOf(OneOf) (v Visitor, err error)
VisitService(Service) (v Visitor, err error)
VisitMethod(Method) (v Visitor, err error)
}
How far can we take this?
SERVICE GENERATION
Srv Framework
HTTP Server gRPC Server
Debug API
App-Level Config
Users Odie Gizmo Odie
HTTP Service
Config
Users Service ConfigModel Repositories
HTTP Handlers Users Handlers
FUTURE TOOLS
Linting & Static Analysis
• Enforce best practices
• Protect production code
• Core Libraries ≠ IDL Police
Mocks & Test Fixtures
• Scenarios of valid state
• Reduce reliance on integration tests
• Developer confidence
gRPC on Mobile
• Reduced payload size
• Leverage streaming APIs
• Global consistency
The incremental march
continues…
Having an ideal is good
Awareness of reality is
essential
THANKS!
Christopher Burnett - Lead Core Libraries
@twoism
Chris Roche - Core Libraries
@rodaine
Watch the video with slide synchronization on
InfoQ.com!
https://www.infoq.com/presentations/api-pb-
grpc

More Related Content

What's hot

Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, Google
Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, GoogleBringing Learnings from Googley Microservices with gRPC - Varun Talwar, Google
Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, GoogleAmbassador Labs
 
HTTP2 and gRPC
HTTP2 and gRPCHTTP2 and gRPC
HTTP2 and gRPCGuo Jing
 
G rpc talk with intel (3)
G rpc talk with intel (3)G rpc talk with intel (3)
G rpc talk with intel (3)Intel
 
Building your First gRPC Service
Building your First gRPC ServiceBuilding your First gRPC Service
Building your First gRPC ServiceJessie Barnett
 
gRPC Design and Implementation
gRPC Design and ImplementationgRPC Design and Implementation
gRPC Design and ImplementationVarun Talwar
 
Performance is not an Option - gRPC and Cassandra
Performance is not an Option - gRPC and CassandraPerformance is not an Option - gRPC and Cassandra
Performance is not an Option - gRPC and CassandraDave Bechberger
 
gRPC: The Story of Microservices at Square
gRPC: The Story of Microservices at SquaregRPC: The Story of Microservices at Square
gRPC: The Story of Microservices at SquareApigee | Google Cloud
 
gRPC or Rest, why not both?
gRPC or Rest, why not both?gRPC or Rest, why not both?
gRPC or Rest, why not both?Mohammad Murad
 
REST vs gRPC: Battle of API's
REST vs gRPC: Battle of API'sREST vs gRPC: Battle of API's
REST vs gRPC: Battle of API'sLuram Archanjo
 
Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.Mihai Iachimovschi
 
Introduction to gRPC
Introduction to gRPCIntroduction to gRPC
Introduction to gRPCPrakash Divy
 
gRPC on .NET Core - NDC Sydney 2019
gRPC on .NET Core - NDC Sydney 2019gRPC on .NET Core - NDC Sydney 2019
gRPC on .NET Core - NDC Sydney 2019James Newton-King
 

What's hot (20)

Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, Google
Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, GoogleBringing Learnings from Googley Microservices with gRPC - Varun Talwar, Google
Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, Google
 
gRPC Overview
gRPC OverviewgRPC Overview
gRPC Overview
 
HTTP2 and gRPC
HTTP2 and gRPCHTTP2 and gRPC
HTTP2 and gRPC
 
G rpc talk with intel (3)
G rpc talk with intel (3)G rpc talk with intel (3)
G rpc talk with intel (3)
 
Building your First gRPC Service
Building your First gRPC ServiceBuilding your First gRPC Service
Building your First gRPC Service
 
Building microservices with grpc
Building microservices with grpcBuilding microservices with grpc
Building microservices with grpc
 
gRPC
gRPCgRPC
gRPC
 
gRPC: Beyond REST
gRPC: Beyond RESTgRPC: Beyond REST
gRPC: Beyond REST
 
gRPC Design and Implementation
gRPC Design and ImplementationgRPC Design and Implementation
gRPC Design and Implementation
 
Grpc present
Grpc presentGrpc present
Grpc present
 
Performance is not an Option - gRPC and Cassandra
Performance is not an Option - gRPC and CassandraPerformance is not an Option - gRPC and Cassandra
Performance is not an Option - gRPC and Cassandra
 
gRPC: The Story of Microservices at Square
gRPC: The Story of Microservices at SquaregRPC: The Story of Microservices at Square
gRPC: The Story of Microservices at Square
 
gRPC in Go
gRPC in GogRPC in Go
gRPC in Go
 
Make gRPC great again
Make gRPC great againMake gRPC great again
Make gRPC great again
 
gRPC or Rest, why not both?
gRPC or Rest, why not both?gRPC or Rest, why not both?
gRPC or Rest, why not both?
 
REST vs gRPC: Battle of API's
REST vs gRPC: Battle of API'sREST vs gRPC: Battle of API's
REST vs gRPC: Battle of API's
 
Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.
 
Introduction to gRPC
Introduction to gRPCIntroduction to gRPC
Introduction to gRPC
 
gRPC on .NET Core - NDC Sydney 2019
gRPC on .NET Core - NDC Sydney 2019gRPC on .NET Core - NDC Sydney 2019
gRPC on .NET Core - NDC Sydney 2019
 
gRPC
gRPCgRPC
gRPC
 

Similar to Generating Unified APIs with Protocol Buffers and gRPC

Microservices and the Art of Taming the Dependency Hell Monster
Microservices and the Art of Taming the Dependency Hell MonsterMicroservices and the Art of Taming the Dependency Hell Monster
Microservices and the Art of Taming the Dependency Hell MonsterC4Media
 
Building a Bank with Go
Building a Bank with GoBuilding a Bank with Go
Building a Bank with GoC4Media
 
A Practical Road to SaaS in Python
A Practical Road to SaaS in PythonA Practical Road to SaaS in Python
A Practical Road to SaaS in PythonC4Media
 
No REST - Architecting Real-time Bulk Async APIs
No REST - Architecting Real-time Bulk Async APIsNo REST - Architecting Real-time Bulk Async APIs
No REST - Architecting Real-time Bulk Async APIsC4Media
 
Evolution of the Netflix API
Evolution of the Netflix APIEvolution of the Netflix API
Evolution of the Netflix APIC4Media
 
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...apidays
 
Building Tomorrow's Web Services
Building Tomorrow's Web ServicesBuilding Tomorrow's Web Services
Building Tomorrow's Web ServicesPat Cappelaere
 
PhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 PluginPhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 PluginHaehnchen
 
An Introduction to Microservices
An Introduction to MicroservicesAn Introduction to Microservices
An Introduction to MicroservicesAd van der Veer
 
#JaxLondon keynote: Developing applications with a microservice architecture
#JaxLondon keynote: Developing applications with a microservice architecture#JaxLondon keynote: Developing applications with a microservice architecture
#JaxLondon keynote: Developing applications with a microservice architectureChris Richardson
 
Developing Applications with a Micro Service Architecture - Chris Richardson
Developing Applications with a Micro Service Architecture - Chris RichardsonDeveloping Applications with a Micro Service Architecture - Chris Richardson
Developing Applications with a Micro Service Architecture - Chris RichardsonJAXLondon2014
 
Pros and Cons of a MicroServices Architecture talk at AWS ReInvent
Pros and Cons of a MicroServices Architecture talk at AWS ReInventPros and Cons of a MicroServices Architecture talk at AWS ReInvent
Pros and Cons of a MicroServices Architecture talk at AWS ReInventSudhir Tonse
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileC4Media
 
High quality ap is with api platform
High quality ap is with api platformHigh quality ap is with api platform
High quality ap is with api platformNelson Kopliku
 
Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle Gaurav Bhardwaj
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsTom Johnson
 
Scaling Push Messaging for Millions of Devices @Netflix
Scaling Push Messaging for Millions of Devices @NetflixScaling Push Messaging for Millions of Devices @Netflix
Scaling Push Messaging for Millions of Devices @NetflixC4Media
 
Cilium:: Application-Aware Microservices via BPF
Cilium:: Application-Aware Microservices via BPFCilium:: Application-Aware Microservices via BPF
Cilium:: Application-Aware Microservices via BPFCynthia Thomas
 

Similar to Generating Unified APIs with Protocol Buffers and gRPC (20)

Microservices and the Art of Taming the Dependency Hell Monster
Microservices and the Art of Taming the Dependency Hell MonsterMicroservices and the Art of Taming the Dependency Hell Monster
Microservices and the Art of Taming the Dependency Hell Monster
 
Building a Bank with Go
Building a Bank with GoBuilding a Bank with Go
Building a Bank with Go
 
A Practical Road to SaaS in Python
A Practical Road to SaaS in PythonA Practical Road to SaaS in Python
A Practical Road to SaaS in Python
 
No REST - Architecting Real-time Bulk Async APIs
No REST - Architecting Real-time Bulk Async APIsNo REST - Architecting Real-time Bulk Async APIs
No REST - Architecting Real-time Bulk Async APIs
 
Evolution of the Netflix API
Evolution of the Netflix APIEvolution of the Netflix API
Evolution of the Netflix API
 
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
 
Building Tomorrow's Web Services
Building Tomorrow's Web ServicesBuilding Tomorrow's Web Services
Building Tomorrow's Web Services
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
PhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 PluginPhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 Plugin
 
An Introduction to Microservices
An Introduction to MicroservicesAn Introduction to Microservices
An Introduction to Microservices
 
#JaxLondon keynote: Developing applications with a microservice architecture
#JaxLondon keynote: Developing applications with a microservice architecture#JaxLondon keynote: Developing applications with a microservice architecture
#JaxLondon keynote: Developing applications with a microservice architecture
 
Developing Applications with a Micro Service Architecture - Chris Richardson
Developing Applications with a Micro Service Architecture - Chris RichardsonDeveloping Applications with a Micro Service Architecture - Chris Richardson
Developing Applications with a Micro Service Architecture - Chris Richardson
 
Pros and Cons of a MicroServices Architecture talk at AWS ReInvent
Pros and Cons of a MicroServices Architecture talk at AWS ReInventPros and Cons of a MicroServices Architecture talk at AWS ReInvent
Pros and Cons of a MicroServices Architecture talk at AWS ReInvent
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy Mobile
 
High quality ap is with api platform
High quality ap is with api platformHigh quality ap is with api platform
High quality ap is with api platform
 
Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIs
 
Scaling Push Messaging for Millions of Devices @Netflix
Scaling Push Messaging for Millions of Devices @NetflixScaling Push Messaging for Millions of Devices @Netflix
Scaling Push Messaging for Millions of Devices @Netflix
 
Cilium:: Application-Aware Microservices via BPF
Cilium:: Application-Aware Microservices via BPFCilium:: Application-Aware Microservices via BPF
Cilium:: Application-Aware Microservices via BPF
 
Kurento cpmx
Kurento cpmxKurento cpmx
Kurento cpmx
 

More from C4Media

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoC4Media
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020C4Media
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsC4Media
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No KeeperC4Media
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like OwnersC4Media
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaC4Media
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideC4Media
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDC4Media
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine LearningC4Media
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at SpeedC4Media
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsC4Media
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsC4Media
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerC4Media
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleC4Media
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeC4Media
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereC4Media
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing ForC4Media
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data EngineeringC4Media
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreC4Media
 
Navigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsNavigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsC4Media
 

More from C4Media (20)

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No Keeper
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like Owners
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 
Navigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsNavigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery Teams
 

Recently uploaded

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
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 businesspanagenda
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
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...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
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 FMESafe Software
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 

Recently uploaded (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
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
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

Generating Unified APIs with Protocol Buffers and gRPC

  • 1. TYPES ALL THE WAY DOWN GENERATING APIS WITH PROTOBUFS AND GRPC
  • 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! https://www.infoq.com/presentations/ api-pb-grpc
  • 3. Presented at QCon New York www.qconnewyork.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  • 4. HI! Christopher Burnett - Lead Core Libraries Formerly Twitter, VSCO @twoism Chris Roche - Core Libraries Formerly VSCO @rodaine
  • 5. CORE LIBRARIES A little about us… • HTTP & gRPC Frameworks • Tooling for Go, Python, and PHP • Rolling out gRPC within Lyft
  • 6. AGENDA • Why choose RPC in the first place? • Working with legacy systems • Disrupting workflows, nicely :) • What we’ve built
  • 7. EVERY TEN YEARS… A furious bout of language and protocol design takes place and a new distributed computing paradigm is announced that is compliant with the latest programming model. - A Note On Distributed Computing, Waldo 1994
  • 8. LOOK FAMILIAR? • CORBA • Thrift • SOAP • WDDX • JSON-RPC • XML-RPC • Avro • HyperMedia • REST • MessagePack
  • 9.
  • 10. A LITTLE HISTORY Like any good story we begin with a PHP monolith… • Active decomp efforts • 100s of Python Microservices - Flask HTTP/REST And to keep things interesting… • gRPC Core and Compositional Services
  • 11. DEFINING A CORE SERVICE • Organizational Primitives - User, Rides, Vehicles • Zero (Service) Dependencies - Databases, caches, etc • Highly Performant
  • 16. REST/JSON: S2S COMMUNICATION POST /api/updateUser HTTP/1.0 Content-Type: application/json { "id": 18446744073709551615, "username": “chris" }
  • 17. ALRIGHT, LET’S PAINT THAT SHED… PUT /api/users HTTP/1.0 Content-Type: application/json { "id": 18446744073709551615, "username": “chris" }
  • 18. PUTTING ON ANOTHER COAT… PUT /api/users/18446744073709551615 HTTP/1.0 Content-Type: application/json { "username": “chris" }
  • 19. FINISHING TOUCHES… PUT /api/v1/users/18446744073709551615 HTTP/1.0 Content-Type: application/json { "username": “chris" }
  • 20. IDLs are pretty great :)
  • 21. IDLS ARE PRETTY GREAT • Single Source of Truth -Primitive definitions • Code Generation -APIs, Clients, Servers, Data Models, Docs, Observability • Extensibility -Plugins for everything else
  • 22. IDL SERVICE DEFINITION package lyft.service.users.v1 service Users { rpc Update(UpdateRequest) UpdateResponse; } message UpdateRequest { uint64 id = 1; string name = 2; }
  • 24. IDL SERVICE DEFINITION — HTTP package lyft.service.users.v1 service Users { option (http.http_server_options).isHttpServer = true; rpc Update(UpdateRequest) returns UpdateResponse { // Override `path` for legacy URL support option (http.http_options).path = "/api/v1/users/:id"; option (http.http_options).method = "PUT"; } }
  • 25. TYPES ON THE WIRE • Simplified API I/O - Structs In, Structs Out • Safety - Big wins for dynamic languages • Transfer Cost - Improved latencies
  • 27. Types on the wire eliminate an entire class of errors
  • 28. TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'
  • 30. HTTP/2.0 • Full Duplex Streaming • Binary Transport • Push • Header Compression
  • 31. WHAT’S NOT SO GREAT?
  • 32. Introducing a new protocol or language can be highly traumatic for teams.
  • 33. “How do I cURL this?”
  • 34. WHAT CAN MAKE THIS BETTER? • Incremental Adoption -Allow teams to opt-in to the new shiny things • Familiarity -Tooling that feels welcoming -Standardized framework patterns • Roll Forward -Wire format first, then the protocol and frameworks
  • 35. How can we make protocol and infra changes flexible and transparent?
  • 36.
  • 37. Service Mesh ENVOY TOPOLOGY Internet Clients “Front” Envoy Legacy PHP Monolith Envoy Go Services Python Services Envoy Envoy MongoDB / DynamoDB Ratelimiting Stats / Tracing Discovery
  • 39.
  • 40. ENVOY: GRPC BRIDGE FILTER Python HTTP Envoy Envoy HTTP/1 POST /GetUser 200 OK gRPC gRPCBridge
  • 41. ENVOY: JSON PROXY FILTER Python HTTP Envoy Envoy HTTP/1 POST /GetUser 200 OK gRPC JSONFILTER
  • 42. With Envoy, services and clients can evolve independently.
  • 44. How can we leverage IDLs beyond the API?
  • 45. ODIE: IDLS MEET THE DATASTORE Type-Safe Repository Driver-Agnostic Client Expression Engine Decorator Middleware Database Driver IDL-Based Model Lifecycle Events MongoDB DynamoDB Spanner BoltDB
  • 46. ODIE: MODELS AS PROTOCOL BUFFERS message User { option (odie.mongo).enabled = true; string id = 1 [(odie.mongo).primary = true, (odie.type).object_id = true]; string name = 2 [(odie.mongo).name = "username"]; int64 date = 3 [(odie.type).datetime = true]; uint32 vers = 4 [(odie.locking).revision = true]; }
  • 47. ODIE: MODELS AS PROTOCOL BUFFERS type UserModel struct { Id bson.ObjectId `bson:"_id"` Name string `bson:"username"` Date time.Time Vers uint32 } func (pb *User) ToModel() *UserModel func (m *UserModel) ToProto() *User
  • 48. ODIE: TYPE-SAFE REPOSITORIES type UserRepo interface { Events() *Events Get(ctx context.Context, id bson.ObjectId) *GetBuilder Put(ctx context.Context, m *UserModel) *PutBuilder Delete(ctx context.Context) *DeleteBuilder Update(ctx context.Context) *UpdateBuilder Query(ctx context.Context) *QueryBuilder }
  • 49. ODIE: THE PLATONIC IDEAL • Zero/Empty value ≅ Nil value - False is semantically the same as null • Fields are not polymorphic - All attributes are singularly typed • Models are rigidly typed - Legacy data is already mappable
  • 50. ODIE: THE REALITY • Zero/Empty value ≅ Nil value - False is semantically the same as null • Fields are not polymorphic - All attributes are singularly typed • Models are rigidly typed - Legacy data is already mappable • true and false …and nil - Allow proto2 syntax models • Need to decomp from existing PHP Doctrine models - Move source of truth without breaking legacy code. • Covariant polymorphic repeated discriminator maps - Enough said.
  • 51. “How do you change the wheels of a moving train?”
  • 52. MOVE THE SOURCE OF TRUTH Entity UserModel Schema Computed Properties Behavior Entity UserModel Computed Properties Behavior UserFields Schema Codegen from the IDL
  • 53. MOVE THE SOURCE OF TRUTH Users Service Envoy Legacy PHP Envoy m.ToProto() pb.ToModel() OdieDoctrine Adapter Odie Repo Legacy ModelPB / gRPC Fields Class
  • 55. PYTHON ENVOY-GRPC CLIENTS // Envoy-gRPC Client class UsersClient(…): def get(self, request) def multiget(self, request) def update(self, request) // Official gRPC client class UsersServiceClient(…): def get(self, request) def multiget(self, request) def update(self, request)
  • 56. Listen to your customers
  • 58. OFFICIAL PYTHON MESSAGES User = _reflection.GeneratedProtocolMessageType('User', (_message.Message,), dict( DESCRIPTOR = _USER, __module__ = 'pb.lyft.user_pb2' )) _sym_db.RegisterMessage(User)
  • 59. PYTHON MESSAGE PROXIES class UserProxy(object): def __init__(self, base_pb): self._base = base_pb @property def id(self): return self._base.id @id.setter def id(self, value): self._base.id = value
  • 60. FURTHER CODE GENERATION • Go/PHP Envoy-aware clients • PB over HTTP clients/server • Observability interceptors • Ergonomics helpers • Response caching • CLI
  • 61. That’s an awful lot of codegen…
  • 62. PROTOC-GEN-STAR (PG*) Code generation framework
 • AST of Lyft primitives • Simplifies code generation • Highly testable Package File Service Method Enum EnumValue Message OneOf Field
  • 63. PG*: WALK THE AST type Visitor interface { VisitPackage(Package) (v Visitor, err error) VisitFile(File) (v Visitor, err error) VisitMessage(Message) (v Visitor, err error) VisitEnum(Enum) (v Visitor, err error) VisitEnumValue(EnumValue) (v Visitor, err error) VisitField(Field) (v Visitor, err error) VisitOneOf(OneOf) (v Visitor, err error) VisitService(Service) (v Visitor, err error) VisitMethod(Method) (v Visitor, err error) }
  • 64. How far can we take this?
  • 65. SERVICE GENERATION Srv Framework HTTP Server gRPC Server Debug API App-Level Config Users Odie Gizmo Odie HTTP Service Config Users Service ConfigModel Repositories HTTP Handlers Users Handlers
  • 66. FUTURE TOOLS Linting & Static Analysis • Enforce best practices • Protect production code • Core Libraries ≠ IDL Police Mocks & Test Fixtures • Scenarios of valid state • Reduce reliance on integration tests • Developer confidence gRPC on Mobile • Reduced payload size • Leverage streaming APIs • Global consistency
  • 68. Having an ideal is good
  • 69. Awareness of reality is essential
  • 70. THANKS! Christopher Burnett - Lead Core Libraries @twoism Chris Roche - Core Libraries @rodaine
  • 71. Watch the video with slide synchronization on InfoQ.com! https://www.infoq.com/presentations/api-pb- grpc