Skip to content

Commit 9f19f04

Browse files
authored
doc(ADR): only public types in public APIs (#8042)
1 parent ebc8f09 commit 9f19f04

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
**Title**: use only public types in public APIs, and aliases are no exceptions
2+
3+
**Status**: proposed <!-- TODO(coryan) - change to accepted before merge -->
4+
5+
**Context**: We want our public APIs to be fully documented, easy to discover,
6+
and *stable*. We need the flexibility to change the implementation details of
7+
our public APIs. We label symbols that are subject to change by placing them
8+
in an `::internal::` or `::${library}_internal::` namespace. This is all well
9+
and good, but sometimes we have used aliases to these internal symbols in
10+
our public APIs. We should not do this, it leaves important parts of the public
11+
API undocumented, and makes it unclear if the API is stable.
12+
13+
**Decision**: Never require (take as an argument) or return an internal type in
14+
the public APIs. If a type is part of the public API, then the type needs to be
15+
moved out of the internal namespace. If possible, just expose an interface
16+
in the public API, and keep the implementation details in the internal
17+
namespace.
18+
19+
**Consequences**: On the positive side, our public APIs become better
20+
documented, more discoverable, and easier to reason about. On the negative
21+
side, we need to ensure any type we consume or return from a public API is
22+
stable. That will constrain the class of changes we can make to these APIs.
23+
24+
We will adopt the ADR first, and change any APIs that do not conform as needed.
25+
Some cases will be difficult, all the APIs using retry and backoff policies
26+
appear somewhat complicated.

0 commit comments

Comments
 (0)