Skip to content

punitpawarapple/swift-grpc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Swift gRPC

A very simple gRPC library to use with Apple's swift-protobuf.


⚠️ There is active work going on here that will result in API changes. ⚠️


Usage

Protobuf outline:

syntax = "proto3"; service HelloService { rpc Send(HelloRequest) returns (HelloResponse) {} } message HelloRequest { string text = 1; } message HelloResponse { string text = 1; }

Build protobuf file with swift-protobuf-plugin and whatever server-side plugin of your choosing, here I'm using Go:

$ protoc --swift_out=YourSwiftClient/Sources --go_out=plugins=grpc:. your-protobuf-file.proto 

Client code:

import Foundation let url = URL(string: "http://localhost:8080")! let session = GrpcSession(url: url) let hello = HelloRequest(text: "Hello, World") try? session.write(path: "/HelloService/Send", data: hello) { bytes in let resp = try? HelloResponse(protobufBytes: bytes) print(resp) }

About

🔮 A very simple gRPC library to use with Apple's swift-protobuf.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Swift 100.0%