Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
grpclib: pure-Python gRPC implementation
Search
Vladimir Magamedov
April 28, 2018
Programming
0
460
grpclib: pure-Python gRPC implementation
Vladimir Magamedov
April 28, 2018
Tweet
Share
More Decks by Vladimir Magamedov
See All by Vladimir Magamedov
Microservices
vmagamedov
0
39
Microservices / gRPC
vmagamedov
1
410
High Performance SQLAlchemy
vmagamedov
5
880
Other Decks in Programming
See All in Programming
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
130
Quine, Polyglot, 良いコード
qnighy
4
650
Amazon Qを使ってIaCを触ろう!
maruto
0
420
Djangoの開発環境で工夫したこと - pre-commit / DevContainer
hiroki_yod
1
280
Tauriでネイティブアプリを作りたい
tsucchinoko
0
380
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
cmp.Or に感動した
otakakot
3
270
[Do iOS '24] Ship your app on a Friday...and enjoy your weekend!
polpielladev
0
120
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
140
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
260
WebAssembly Unleashed: Powering Server-Side Applications
chrisft25
0
270
romajip: 日本の住所CSVデータを活用した英語住所変換ライブラリを作った話
sangunkang
0
300
Featured
See All Featured
Faster Mobile Websites
deanohume
305
30k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Writing Fast Ruby
sferik
627
61k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Building Your Own Lightsaber
phodgson
103
6.1k
The Pragmatic Product Professional
lauravandoore
31
6.3k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Embracing the Ebb and Flow
colly
84
4.5k
Transcript
grpclib @vmagamedov, Evo
HTTP/2 protocol • Binary • Multiplexing • Bidirectional streams •
Flow control • Headers compression
gRPC protocol = HTTP/2 + • Deadlines • Cancellation •
Metadata (extensibility) • Declarative service definition language (.proto files) • Binary messages encoding (protobuf by default) • Streaming requests and responses • Authentication, Introspection, Load balancing x2
gRPC request: HEADERS :method = POST :scheme = http :path
= /cafe.CoffeeMachine/MakeLatte :authority = cafe.svc:50051 content-type = application/grpc+proto te = trailers DATA ... length-prefixed message(s) ... DATA
gRPC response: HEADERS :status = 200 content-type = application/grpc+proto DATA
... length-prefixed message(s) ... DATA HEADERS # trailers grpc-status = 0 # OK
• grpcio by Google • Python 2.7, >=3.4 • threads
• C++ based core: server and client • grpclib by Me & contributors • Python >= 3.5 • async/await • pure-Python, based on awesome hyper-h2 project
Definition syntax = "proto3"; package helloworld; service Greeter { rpc
SayHello (HelloRequest) returns (HelloReply) {} } message HelloRequest { string name = 1; } message HelloReply { string message = 1; }
class Greeter(GreeterBase): async def SayHello(self, stream): request = await stream.recv_message()
message = 'Hello, {}!'.format(request.name) await stream.send_message(HelloReply(message=message)) server = Server([Greeter()], loop=loop) loop.run_until_complete(server.start('127.0.0.1', 50051)) Server
channel = Channel('greeter.svc', 50051, loop=loop) stub = GreeterStub(channel) async def
make_request(): response = await stub.SayHello(HelloRequest(name='World')) assert response.message == 'Hello, World!' Client
None
pip3 install grpclib Have fun! Come work with us (Evo)
;-)