0Pricing
gRPC & High Performance APIs · درس

انعكاس الخادم والعملاء الديناميكيون

فعّلوا انعكاس خادم gRPC كي تتمكّن الأدوات والعملاء من اكتشاف الخدمات ومخططات الرسائل أثناء التشغيل دون بدائل مُجمّعة مسبقًا.

انعكاس الخادم والعملاء الديناميكيون درس مجاني في gRPC & High Performance APIs على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في gRPC & High Performance APIs، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة gRPC & High Performance APIs 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

The Stub Discovery Problem

Normally a client needs the .proto files compiled into stubs to call a service. That is inconvenient for debugging tools and generic clients.

Server reflection lets a server describe its own API at runtime.

What Reflection Exposes

The reflection service answers questions like:

  • Which services does this server host?
  • What methods does a service have?
  • What are the request/response message schemas?

It returns the underlying FileDescriptorProto data.

Enabling Reflection in Go

Register the reflection service on your gRPC server with a single call.

import 'google.golang.org/grpc/reflection'

s := grpc.NewServer()
pb.RegisterServiceServer(s, &svc{})
reflection.Register(s)

Enabling Reflection in Java

In Java add the ProtoReflectionService when building the server.

Server server = ServerBuilder.forPort(9090)
  .addService(new MyServiceImpl())
  .addService(ProtoReflectionService.newInstance())
  .build();

Listing Services with grpcurl

With reflection on, grpcurl can list services without a proto file.

grpcurl -plaintext localhost:9090 list

Describing a Method

You can inspect a method's input and output schema directly from the server.

grpcurl -plaintext localhost:9090 describe my.pkg.Service.GetUser

Calling Without Stubs

Reflection lets you invoke methods by sending JSON; the tool maps it to protobuf using the discovered schema.

grpcurl -plaintext -d '{"id": 7}' localhost:9090 my.pkg.Service.GetUser

Dynamic Clients in Code

Libraries can build messages dynamically from descriptors fetched via reflection, enabling generic gateways and admin tools that work against any gRPC server.

The Reflection Protocol

Reflection is itself a gRPC service: grpc.reflection.v1.ServerReflection. It uses a bidirectional stream where clients ask and the server streams back descriptors.

Security Considerations

Reflection reveals your entire API surface. In production:

  • Disable it on public-facing edges, or
  • Restrict it to internal networks / authenticated callers

It is invaluable in dev and staging.

When to Use It

Reflection shines for debugging, building generic UIs (like BloomRPC/Postman), and admin tooling. For high-throughput app clients, precompiled stubs are still faster and safer.

Quick Check

Test your reflection knowledge.

Recap

You learned server reflection and dynamic clients:

  • Reflection lets a server describe its own API at runtime
  • Enable it with reflection.Register (Go) or ProtoReflectionService (Java)
  • Tools like grpcurl can list, describe, and call without stubs
  • Dynamic clients build messages from fetched descriptors
  • Restrict reflection in production for security

الأسئلة الشائعة

هل درس «انعكاس الخادم والعملاء الديناميكيون» مجاني؟

نعم — نص درس «انعكاس الخادم والعملاء الديناميكيون» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة gRPC & High Performance APIs، انتقل إلى CoddyKit PRO. تتضمن دورة gRPC & High Performance APIs 4 دروس في المجموع.

ماذا ستتعلم في «انعكاس الخادم والعملاء الديناميكيون»؟

فعّلوا انعكاس خادم gRPC كي تتمكّن الأدوات والعملاء من اكتشاف الخدمات ومخططات الرسائل أثناء التشغيل دون بدائل مُجمّعة مسبقًا. تتمرن على gRPC & High Performance APIs مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ gRPC & High Performance APIs؟

لا تُشترط خبرة سابقة. gRPC & High Performance APIs على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «انعكاس الخادم والعملاء الديناميكيون»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس gRPC & High Performance APIs هذا؟

نعم. كل درس في gRPC & High Performance APIs يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. دمج gRPC-Web
  2. gRPCurl وBloomRPC
  3. أنماط اكتشاف الخدمات
  4. انعكاس الخادم والعملاء الديناميكيون
← العودة إلى gRPC & High Performance APIs