Akış RPC’leri: Sunucu, İstemci ve Çift Yönlü
Tekli çağrıların ötesine geçin ve tek bir çağrı üzerinden ileti dizileri göndermek için gRPC’nin üç akış modunu öğrenin.
Akış RPC’leri: Sunucu, İstemci ve Çift Yönlü, CoddyKit'te ücretsiz bir gRPC & High Performance APIs dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, gRPC & High Performance APIs öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. gRPC & High Performance APIs kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Beyond Unary
A unary RPC is one request, one response. But many problems need a sequence of messages — feeds, uploads, chat.
gRPC offers three streaming modes built on HTTP/2 streams.
The Four Method Shapes
In a .proto service you can declare:
- Unary: one in, one out.
- Server streaming: one in, many out.
- Client streaming: many in, one out.
- Bidirectional: many in, many out.
Declaring Streams in Proto
The stream keyword marks a parameter as a stream.
service Feed {
rpc Watch (WatchRequest) returns (stream Event);
rpc Upload (stream Chunk) returns (UploadResult);
rpc Chat (stream Message) returns (stream Message);
}Server Streaming
The client sends one request; the server replies with many messages until it closes the stream.
Great for: live feeds, large result sets, progress updates.
// Server side (Go-style pseudocode)
func (s *server) Watch(req *WatchRequest, stream Feed_WatchServer) error {
for _, e := range events {
stream.Send(e)
}
return nil
}Client Streaming
The client sends many messages, then the server returns a single response.
Great for: file uploads, batched ingestion, aggregations.
// Server reads the whole client stream, then replies once
func (s *server) Upload(stream Feed_UploadServer) error {
for {
chunk, err := stream.Recv()
if err == io.EOF {
return stream.SendAndClose(&UploadResult{})
}
}
}Bidirectional Streaming
Both sides send streams independently over the same call. Messages can interleave freely.
Great for: chat, real-time collaboration, interactive protocols.
Why It's Efficient
All four shapes ride a single HTTP/2 stream — no new connection per message.
Multiplexing means many streaming calls share one connection without head-of-line blocking.
Flow Control
HTTP/2 provides built-in flow control, so a slow reader naturally backpressures a fast writer.
This prevents a streaming server from overwhelming a client that can't keep up.
Ending a Stream
Streams close explicitly:
- Server streaming ends when the server returns.
- Client streaming ends when the client signals end-of-stream and the server replies.
- Bidirectional ends when both halves complete or an error/cancel occurs.
Errors & Cancellation
Either side can cancel or fail mid-stream. The peer receives a status code and should clean up.
Always handle EOF and error returns from Recv() / Send() to avoid leaks.
Choosing a Mode
Pick by data shape:
- One-shot request/response: unary.
- Push many results: server streaming.
- Send many, get a summary: client streaming.
- Continuous two-way: bidirectional.
Quick Check
Test your understanding of streaming RPCs.
Recap
You learned gRPC's streaming modes.
- Unary, server streaming, client streaming, and bidirectional.
- Mark streams with the
streamkeyword in proto. - All ride a single multiplexed HTTP/2 stream with built-in flow control.
- Choose the mode that matches your data's shape.
Sıkça Sorulan Sorular
“Akış RPC’leri: Sunucu, İstemci ve Çift Yönlü” dersi ücretsiz mi?
Evet — “Akış RPC’leri: Sunucu, İstemci ve Çift Yönlü” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve gRPC & High Performance APIs kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. gRPC & High Performance APIs kursu toplamda 4 dersten oluşur.
“Akış RPC’leri: Sunucu, İstemci ve Çift Yönlü” dersinde ne öğreneceğim?
Tekli çağrıların ötesine geçin ve tek bir çağrı üzerinden ileti dizileri göndermek için gRPC’nin üç akış modunu öğrenin. gRPC & High Performance APIs ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
gRPC & High Performance APIs öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te gRPC & High Performance APIs, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Akış RPC’leri: Sunucu, İstemci ve Çift Yönlü” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu gRPC & High Performance APIs dersinde kod yazıp çalıştırabilir miyim?
Evet. Her gRPC & High Performance APIs dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Protobuf Şema Tanımlama
- gRPC Kodu Oluşturma
- Basit Tekli gRPC Hizmeti
- Akış RPC’leri: Sunucu, İstemci ve Çift Yönlü