Aucune description

George Barnett 03fe0fa866 Update examples to use channel pool (#1293) il y a 4 ans
.github d6336e075e Add a pooled channel il y a 4 ans
Examples 9e900436da Bump version of Google's SpeechToText Example Podfile (#1142) il y a 4 ans
FuzzTesting 01bd56e270 Merge pull request from GHSA-2jx2-qcm4-rf9h il y a 4 ans
Performance c881363e88 Use channel pool in QPS benchmarks (#1287) il y a 4 ans
Sources 03fe0fa866 Update examples to use channel pool (#1293) il y a 4 ans
Tests 988ee3fcc9 Provide more context to failing RPCs from the connection pool (#1292) il y a 4 ans
dev 1d968f50cf Bump version number to 1.4.2 (#1280) il y a 4 ans
docs 03fe0fa866 Update examples to use channel pool (#1293) il y a 4 ans
scripts 529d6914ca Use sync options to get the http2 stream ID (#1229) il y a 4 ans
.gitignore f6c6762fab Add a unary server benchmark (#1074) il y a 5 ans
.gitmodules 63c6acfa40 Move CgRPC, gRPC, and QuickProto to "Sources" directory and add new top-level Package.swift. il y a 9 ans
.swiftformat baa4c3cd1c A more general channel provider (#1162) il y a 4 ans
AUTHORS 0aa90a79ee Relicense to Apache 2, change owners to "the gRPC Authors". il y a 8 ans
CGRPCZlib.podspec bce5b8df6b Update Cocoapods for 1.4.2 (#1281) il y a 4 ans
CODE-OF-CONDUCT.md 5ef0870727 Add/update GOVERNANCE.md, CODE-OF-CONDUCT.md and CONTRIBUTING.md (#595) il y a 6 ans
CONTRIBUTING.md 5ef0870727 Add/update GOVERNANCE.md, CODE-OF-CONDUCT.md and CONTRIBUTING.md (#595) il y a 6 ans
GOVERNANCE.md 5ef0870727 Add/update GOVERNANCE.md, CODE-OF-CONDUCT.md and CONTRIBUTING.md (#595) il y a 6 ans
LICENSE 6dde0518ca Revert to Apache 2.0 license verbatim [skip ci] (#504) il y a 6 ans
MAINTAINERS.md e0c70ce6f8 Add MAINTAINERS.md. (#564) (#576) il y a 6 ans
Makefile c5578d48df Add a codegen option to allow stub names to not have their first character lowercased (#1123) il y a 4 ans
NOTICES.txt 31003a1593 Add allocation counting tests (#1150) il y a 4 ans
PATENTS 36f2bde28e Add PATENTS declaration il y a 9 ans
Package.swift 1b527c9a29 Update swift-argument-parser version (#1263) il y a 4 ans
README.md 5e4aeb589e Add note to README about async/await support. (#1269) il y a 4 ans
SECURITY.md 7fbc418471 Add a security policy. (#1193) il y a 4 ans
gRPC-Swift-Plugins.podspec bce5b8df6b Update Cocoapods for 1.4.2 (#1281) il y a 4 ans
gRPC-Swift.podspec bce5b8df6b Update Cocoapods for 1.4.2 (#1281) il y a 4 ans

README.md

CI Latest Version

gRPC Swift

This repository contains a gRPC Swift API and code generator.

It is intended for use with Apple's SwiftProtobuf support for Protocol Buffers. Both projects contain code generation plugins for protoc, Google's Protocol Buffer compiler, and both contain libraries of supporting code that is needed to build and run the generated code.

APIs and generated code is provided for both gRPC clients and servers, and can be built either with Xcode or the Swift Package Manager. Support is provided for all four gRPC API styles (Unary, Server Streaming, Client Streaming, and Bidirectional Streaming) and connections can be made either over secure (TLS) or insecure channels.

Versions

gRPC Swift has recently been rewritten on top of SwiftNIO as opposed to the core library provided by the gRPC project.

Version Implementation Branch protoc Plugin CocoaPod Support
1.x SwiftNIO main protoc-gen-grpc-swift gRPC-Swift Actively developed and supported
0.x gRPC C library cgrpc protoc-gen-swiftgrpc SwiftGRPC No longer developed; security fixes only

The remainder of this README refers to the 1.x version of gRPC Swift.

Experimental async/await Support

Swift 5.5 introduces new language features for concurrency. One such feature is async/await.

gRPC Swift includes experimental support for async/await. While support is experimental, async/await releases of gRPC Swift do not guarantees a stable API. Features and APIs may change between async/await releases.

To ensure the 1.x release series does maintain a stable API, async/await releases will be branched from stable releases and tagged in the following format: X.Y.Z-async-await.N. Where X.Y.Z indicates the tag of the stable release from which the branch was created and N indicates a release number on that branch.

The protoc-gen-grpc-swift options for generating async/await style clients and servers are described in docs/plugin.md.

Supported Platforms

gRPC Swift's platform support is identical to the platform support of Swift NIO.

Note that gRPC Swift uses NIO 2 and requires Swift to be version 5.2 or higher.

Getting gRPC Swift

There are two parts to gRPC Swift: the gRPC library and an API code generator.

Getting the gRPC library

Swift Package Manager

The Swift Package Manager is the preferred way to get gRPC Swift. Simply add the package dependency to your Package.swift:

dependencies: [
  .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.0.0")
]

...and depend on "GRPC" in the necessary targets:

.target(
  name: ...,
  dependencies: [.product(name: "GRPC", package: "grpc-swift")]
]
Xcode

From Xcode 11 it is possible to add Swift Package dependencies to Xcode projects and link targets to products of those packages; this is the easiest way to integrate gRPC Swift with an existing xcodeproj.

Manual Integration

Alternatively, gRPC Swift can be manually integrated into a project:

  1. Build an Xcode project: swift package generate-xcodeproj,
  2. Add the generated project to your own project, and
  3. Add a build dependency on GRPC.

CocoaPods

gRPC Swift is currently available from CocoaPods. To integrate, add the following line to your Podfile:

    pod 'gRPC-Swift', '~> 1.0.0'

Then, run pod install from command line and use your project's generated .xcworkspace file. You might also need to add use_frameworks! to your Podfile.

⚠️ If you have conficting modules as a result of having a transitive dependency on 'gRPC-Core' see grpc/grpc-swift#945.

Getting the protoc Plugins

Binary releases of protoc, the Protocol Buffer Compiler, are available on GitHub.

To build the plugins, run make plugins in the main directory. This uses the Swift Package Manager to build both of the necessary plugins: protoc-gen-swift, which generates Protocol Buffer support code and protoc-gen-grpc-swift, which generates gRPC interface code.

To install these plugins, just copy the two executables (protoc-gen-swift and protoc-gen-grpc-swift) that show up in the main directory into a directory that is part of your PATH environment variable. Alternatively the full path to the plugins can be specified when using protoc.

Alternatively, you can get the latest precompiled version of the plugins by adding the following line to your Podfile:

    pod 'gRPC-Swift-Plugins'

The plugins are available in the Pods/gRPC-Swift-Plugins/ folder afterwards.

Examples

gRPC Swift has a number of tutorials and examples available. They are split across two directories:

  • /Sources/Examples contains examples which do not require additional dependencies and may be built using the Swift Package Manager.
  • /Examples contains examples which rely on external dependencies or may not be built by the Swift Package Manager (such as an iOS app).

Some of the examples are accompanied by tutorials, including:

  • A quick start guide for creating and running your first gRPC service.
  • A basic tutorial covering the creation and implementation of a gRPC service using all four call types as well as the code required to setup and run a server and make calls to it using a generated client.
  • An interceptors tutorial covering how to create and use interceptors with gRPC Swift.

Documentation

The docs directory contains documentation, including:

Security

Please see SECURITY.md.

License

gRPC Swift is released under the same license as gRPC, repeated in LICENSE.

Contributing

Please get involved! See our guidelines for contributing.