-
Notifications
You must be signed in to change notification settings - Fork 424
Document what constitutes public API #2175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+94
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
Sources/GRPCCore/Documentation.docc/Articles/Public-API.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,93 @@ | ||||||
# Public API | ||||||
|
||||||
Understand what constitutes the public API of gRPC Swift and the commitments | ||||||
made by the maintainers. | ||||||
|
||||||
## Overview | ||||||
|
||||||
The gRPC Swift project uses [Semantic Versioning 2.0.0][0] which requires | ||||||
projects to declare their public API. This document describes what is and isn't | ||||||
part of the public API; commitments the maintainers make relating to the API; | ||||||
and guidelines for users. | ||||||
|
||||||
For clarity the project is comprised of the following Swift packages: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
- [grpc/grpc-swift][1], | ||||||
- [grpc/grpc-swift-nio-transport][2], | ||||||
- [grpc/grpc-swift-protobuf][3], and | ||||||
- [grpc/grpc-swift-extras][4]. | ||||||
|
||||||
## What _is_ and _isn't_ public API | ||||||
|
||||||
### Library targets | ||||||
|
||||||
All library targets made available as package products as considered to be | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
public API. Examples of these include `GRPCCore` and `GRPCProtobuf`. | ||||||
|
||||||
> Exceptions: | ||||||
> Targets with names starting with an underscore (`_`) aren't public API. | ||||||
### Symbols | ||||||
|
||||||
All publicly exposed symbols (i.e. symbols which are declared as `public`) | ||||||
within public library targets or those which are re-exported from non-public | ||||||
targets are part of the public API. Examples include `Metadata`, | ||||||
`ServiceConfig`, and `GRPCServer`. | ||||||
|
||||||
> Exceptions: | ||||||
> - Symbols starting with an underscore (`_`), for example `_someFunction()` and | ||||||
> `_AnotherType` aren't public API. | ||||||
> - Initializers where the first character of the first parameter label is an | ||||||
> underscore, for example `init(_foo:)` aren't public API. | ||||||
### Configuration and inputs | ||||||
|
||||||
Any configuration, input, and interfaces to executable products which have | ||||||
inputs (such as command line arguments, or configuration files) are considered | ||||||
to be public API. Examples of these include the configuration file passed to the | ||||||
Swift Package Manager build plugin for generating stubs provided by | ||||||
[grpc-swift-protobuf][3]. | ||||||
|
||||||
> Exceptions: | ||||||
> - Executable _targets_ which aren't exposed as executable _products_. | ||||||
## Commitments made by the maintainers | ||||||
|
||||||
Without releasing a new major version, the gRPC Swift maintainers commit to not | ||||||
adding any new types to the global namespace without a "GRPC" prefix. | ||||||
|
||||||
To illustrate this, the maintainers may: | ||||||
1. Add a new type to an existing module called `GRPCPanCakes` but will not add a | ||||||
new type called `PanCakes` to an existing module. | ||||||
2. Add a new top-level function to an existing module called `grpcRun()` but | ||||||
won't add a new top-level function called `run()`. | ||||||
3. Add a new module called `GRPCFoo`. Any symbols added to the new module at the | ||||||
point the module becomes API aren't required to have a "GRPC" prefix; symbols | ||||||
added after that point will be prefixed as required by (1) and (2). | ||||||
|
||||||
This allows the project to follow Semantic versioning without breaking adopter | ||||||
code in minor and patch releases. | ||||||
|
||||||
## Guidelines for users | ||||||
|
||||||
In order to not have your code broken by a gRPC Swift update you should only use | ||||||
the public API as described above. There are a number of other guidelines you | ||||||
should follow as well: | ||||||
|
||||||
1. You _may_ conform your own types to protocols provided by gRPC Swift. | ||||||
2. You _may_ conform types provided by gRPC Swift to your own protocols. | ||||||
3. You _mustn't_ conform types provided by gRPC Swift to protocols that you | ||||||
don't own, and you mustn't conform types you don't own to protocols provided | ||||||
by gRPC Swift. | ||||||
4. You _may_ extend types provided by gRPC Swift at `package`, `internal`, | ||||||
`private` or `fileprivate` level. | ||||||
5. You _may_ extend types provided by gRPC Swift at `public` access level if | ||||||
doing so means that a symbol clash is impossible (such as including a type | ||||||
you own in the signature, or prefixing the method with the namespace of your | ||||||
package in much the same way that gRPC Swift will prefix new symbols). | ||||||
|
||||||
[0]: https://semver.org | ||||||
[1]: https://github.com/grpc/grpc-swift | ||||||
[2]: https://github.com/grpc/grpc-swift-nio-transport | ||||||
[3]: https://github.com/grpc/grpc-swift-protobuf | ||||||
[4]: https://github.com/grpc/grpc-swift-extras |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ as tutorials. | |
### Project Information | ||
|
||
- <doc:Compatibility> | ||
- <doc:Public-API> | ||
|
||
### Getting involved | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.