George Barnett 2ed95d8573 Update dependency requirements and docs (#2188) vor 10 Monaten
..
Sources 9639fe95bd Use the protoc build plugin in examples (#2171) vor 10 Monaten
.gitignore cf29048827 Make examples standalone packages (#2067) vor 1 Jahr
Package.swift 2ed95d8573 Update dependency requirements and docs (#2188) vor 10 Monaten
README.md f20f91669b Add `echo-metadata` example (#2182) vor 10 Monaten

README.md

Echo

This example demonstrates all four RPC types using a simple 'echo' service and client and the SwiftNIO based HTTP/2 transport.

Overview

An "echo" command line tool that uses generated stubs for an 'echo' service which allows you to start a server and to make requests against it for each of the four RPC types.

The tool uses the SwiftNIO HTTP/2 transport.

Prerequisites

You must have the Protocol Buffers compiler (protoc) installed. You can find the instructions for doing this in the gRPC Swift Protobuf documentation. The swift commands below are all prefixed with PROTOC_PATH=$(which protoc), this is to let the build system know where protoc is located so that it can generate stubs for you. You can read more about it in the gRPC Swift Protobuf documentation.

Usage

Build and run the server using the CLI:

$ PROTOC_PATH=$(which protoc) swift run echo serve
Echo listening on [ipv4]127.0.0.1:1234

Use the CLI to make a unary 'Get' request against it:

$ PROTOC_PATH=$(which protoc) swift run echo get --message "Hello"
get → Hello
get ← Hello

Use the CLI to make a bidirectional streaming 'Update' request:

$ PROTOC_PATH=$(which protoc) swift run echo update --message "Hello World"
update → Hello
update → World
update ← Hello
update ← World

Get help with the CLI by running:

$ PROTOC_PATH=$(which protoc) swift run echo --help