gRPC Swift follows Semantic Versioning 2.0.0 (SemVer) which requires that projects declare a public API.
For the purpose of this document we consider the gRPC Swift public API to be limited to:
GRPC module (i.e., code in in Sources/GRPC), andprotoc-gen-grpc-swift plugin.Below we cover what consitutes the public API of each, how to use them in an
acceptable manner, and compatability between GRPC and modules generated by
protoc-gen-grpc-swift.
GRPC and Generated ModulesAll exported types and methods from the GRPC module and those
generated by protoc-gen-grpc-swift are considered public API except for the
following:
_)_)_)Examples
Server.insecure(group:) is part of the public API._GRPCClientChannelHandler.channelRead(context:data:) is not part of the
public API, the type _GRPCClientChannelHandler starts with an underscore.EmbeddedChannel._configureForEmbeddedServerTest() is not part of the
public API, the method starts with an underscore.In gRPC Swift, and more generally Swift, it is only acceptable to conform a type to a protocol if you control either the type, the protocol, or both.
GRPC or generated code to protocols
which you do not own.GRPC or generated
code for types you do not own.Examples
extension MyMessageSerializer: MessageSerializer { ... } is acceptable
assuming MyMessageSerializer exists in your own codebase.extension GRPCPayloadSerializer: DebugStringConvertible { ... } is not
acceptable, GRPCPayloadSerializer is defined in GRPC and
DebugStringConvertible is a standard library protocol.GRPC or Generated TypesExtending GRPC or generated types with private or internal methods and
properties is always allowed.
In order to avoid the potential for clashing names, extending GRPC or
generated types with public methods and properties is acceptable if:
Examples
The following is not acceptable since it is public and does not use a type owned by the implementer of the extension.
extension Server.Builder {
public func withSignalHandler(_ handler: @escaping (Int) -> Void) -> Self {
...
}
}
The following is acceptable, MySignal is defined in the same module as the
extension and is used as a non-default argument.
public struct MySignal {
public var signal: Int
}
extension Server.Builder {
public func withSignalHandler(_ handler: @escaping (MySignal) -> Void) -> Self {
...
}
}
The following is acceptable because the method is internal.
extension Server.Builder {
internal func withSignalHandler(_ handler: @escaping (Int) -> Void) -> Self {
...
}
}
GRPC team makeBefore releasing a new major version, i.e. gRPC Swift 2.0.0, we promise that:
GRPC or gRPC.We may deprecate APIs before the next major release, however, they will remain supported.
Examples
GRPCChannelPoolGRPCTestKitgRPCRunChannelPoolTestKitrungRPC Swift generates code via its protoc plugin protoc-gen-grpc-swift.
In order to develop the library over time without breaking existing generated
code it is important to lay out any API and compatability guarantees.
Before releasing a new major version, i.e. gRPC Swift 2.0.0, we promise that:
GRPC module will be backward compatible with all code generated by
the protoc-gen-grpc-swift plugin.Examples
protoc-gen-grpc-swift 1.3.0 will always be compatible
with GRPC 1.3.0 and higher.protoc-gen-grpc-swift 1.5.0 offers no compatability
guarantees compatible with GRPC versions lower than 1.5.0.