From REST to gRPC:
Joe Runde IBM @joerunde Michael Keeling IBM @michaelkeeling
From REST to gRPC: An API Evolution Story Joe Runde Michael - - PowerPoint PPT Presentation
From REST to gRPC: An API Evolution Story Joe Runde Michael Keeling IBM IBM @joerunde @michaelkeeling 2 What is gRPC? Open source R emote P rocedure C all framework 3 What is gRPC? Open source R emote P rocedure C all framework a
Joe Runde IBM @joerunde Michael Keeling IBM @michaelkeeling
2
3
4
“… a modern, bandwidth and CPU efficient, low latency way to create massively distributed systems that span data centers”
5
6
7
8
9
10
11
12
headers = {} headers.put(“X-FooBar-User”, user.getFooBarID()) headers.put(“FooBarTransaction”, app.getNextTxnIDAtomic()) headers.put(“FooBarAlgoType”, ApproximateFoo.toHeaderString())
13
Public class Foo { @JsonProperty(name=”foo_id”) String id; @JsonProperty(name=”bar”) int bar; ... }
14
Public class Foo { ... public Foo(@JsonProperty(“foo_id”,required=true) String id, @JsonProperty(“bar”,required=true) int bar) { ... } }
15
request = FooService.RequestBuilder() .setId(foo.getId()) .setBar(foo.getBar())... .build(); response = fooClient.DoFooBar(request);
16
17
18
19
20
21
22
23
Phase I
24
gRPC: rpc AddFoo(Foo) returns FooID; rpc GetFoo(FooID) returns Foo;
25
REST: POST /api/foo GET /api/foo/{foo_id}
gRPC: message Foo { FooID id = 1; repeated Bar bars = 2; } message FooID { string val = 1; }
26
REST: POST /api/foo GET /api/foo/{foo_id}
gRPC: rpc AddBar(Bar) returns BarID; rpc GetFoo(BarID) returns Bar;
27
REST: POST /api/foo/{foo_id}/bar GET /api/foo/{foo_id}/bar/ {bar_id}
gRPC: rpc AddBar(Bar) returns BarID; rpc GetFoo(BarID) returns Bar;
28
REST: POST /api/foo/{foo_id}/bar GET /api/foo/{foo_id}/bar/ {bar_id}
gRPC: message Bar{ BarID id = 1; int baz = 2; } message BarID { FooID foo_id = 1; string bar_id = 2; }
29
REST: POST /api/foo/{foo_id}/bar GET /api/foo/{foo_id}/bar/ {bar_id}
30
Bar service: /api/foo/{foo_id}/bar/{bar_id} Buzz service: /api/foo/{foo_id}/buzz/{buzz_id}
Phase II
31
32
33
34
Code Package is allowed to use
35
Rest Service Business Logic Datastore Access
Models
Models
36
Code Package is allowed to use Rest Service
Business Logic Datastore Access
gRPC Service
37
38
39
40
Phase III
41
42
43
44
request = Object::const_get( ”FooBar::#{message_name}").decode_json(json) response = client.method(method_name.to_sym) .call(request)
45
46
47
Phase IV
48
49
50
51
52
Models
Rest Service
Business Logic Datastore Access
gRPC Service
FooBar Service Service
53
Models
Business Logic Datastore Access
gRPC Service
FooBar Service gRPC Clients
REST Service
FooBar Proxy Service
54
55
56
57
58
59
60
61
62
63
64
65
66
Michael Keeling @michaelkeeling neverletdown.net Joe Runde @joerunde
68
69
70
71
72