Skip to main content

gRPC Intro


gRPC Intro

Get started with Zilla by deploying our Docker Compose stack. Before proceeding, you should have Docker Composeopen in new window installed.

Echo on a Kafka event stream

Running this Zilla sample will create a gRPC service to echo any message sent through a Kafka topic.

Setup

Create each of these files zilla.yaml, docker-compose.yaml, and echo.proto in the same directory.

zilla.yaml
name: gRPC-example
bindings:

# Proxy service entrypoint
  north_tcp_server:
    type: tcp
    kind: server
    options:
      host: 0.0.0.0
      port: 7151
    exit: north_http_server
  north_http_server:
    type: http
    kind: server
    options:
      versions:
        - h2
      access-control:
        policy: cross-origin
    exit: north_grpc_server

# gRPC service definition
  north_grpc_server:
    type: grpc
    kind: server
    options:
      services:
        - proto/echo.proto
    routes:
      - when:
          - method: example.EchoService/*
        exit: north_grpc_kafka_mapping

# Proxy a gRPC service to a Kafka topic
  north_grpc_kafka_mapping:
    type: grpc-kafka
    kind: proxy
    routes:
      - when:
          - method: example.EchoService/*
        exit: north_kafka_cache_client
        with:
          capability: produce
          topic: echo-messages
          acks: leader_only
          reply-to: echo-messages
  north_kafka_cache_client:
    type: kafka
    kind: cache_client
    exit: south_kafka_cache_server
  south_kafka_cache_server:
    type: kafka
    kind: cache_server
    options:
      bootstrap:
        - echo-messages
    exit: south_kafka_client
  south_kafka_client:
    type: kafka
    kind: client
    exit: south_tcp_client
  south_tcp_client:
    type: tcp
    kind: client
    options:
      host: ${{env.KAFKA_HOST}}
      port: ${{env.KAFKA_PORT}}
    routes:
      - when:
          - cidr: 0.0.0.0/0








































 



 

 

























Run Zilla and Kafka

docker-compose up -d

Send a greeting

docker run -v ./echo.proto:/proto/echo.proto -it --rm fullstorydev/grpcurl \
-plaintext -proto proto/echo.proto -d '{"message":"Hello World"}' host.docker.internal:7151 example.EchoService.EchoSimple

Remove the running containers

docker-compose down

See more of what Zilla can do

Go deeper into this concept with the grpc.kafka.echoopen in new window example.

Going Deeper

Try out more gRPC examples: