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
490
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
42
Microservices / gRPC
vmagamedov
1
420
High Performance SQLAlchemy
vmagamedov
5
880
Other Decks in Programming
See All in Programming
Rails産でないDBを Railsに引っ越すHACK - Omotesando.rb #110
lnit
1
160
FastMCPでMCPサーバー/クライアントを構築してみる
ttnyt8701
2
130
AIコーディング道場勉強会#2 君(エンジニア)たちはどう生きるか
misakiotb
1
110
データベースコネクションプール(DBCP)の変遷と理解
fujikawa8
1
240
Cursor AI Agentと伴走する アプリケーションの高速リプレイス
daisuketakeda
1
100
ワンバイナリWebサービスのススメ
mackee
10
7.7k
Using AI Tools Around Software Development
inouehi
0
1.2k
複数アプリケーションを育てていくための共通化戦略
irof
10
3.8k
イベントストーミングから始めるドメイン駆動設計
jgeem
4
810
Javaに鉄道指向プログラミング (Railway Oriented Pro gramming) のエッセンスを取り入れる/Bringing the Essence of Railway-Oriented Programming to Java
cocet33000
2
530
型付きアクターモデルがもたらす分散シミュレーションの未来
piyo7
0
750
ワイがおすすめする新潟の食 / 20250530phpconf-niigata-eve
kasacchiful
0
300
Featured
See All Featured
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Code Reviewing Like a Champion
maltzj
524
40k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
KATA
mclloyd
29
14k
Making the Leap to Tech Lead
cromwellryan
134
9.3k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.6k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.6k
Designing for Performance
lara
609
69k
Music & Morning Musume
bryan
46
6.6k
The Cult of Friendly URLs
andyhume
79
6.4k
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)
;-)