Repository navigation
Conversation
The package of an internal service exports nothing. Python's `__init__.py` has no exports, TypeScript has no `index.ts` and marks each declaration `@internal`, and .NET types are `internal`.
Contributor
Author
|
Moved to |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed?
This PR adds
@nexus.internal, which marks an interface that only an SDK calls, so its package exports nothing.__init__.pyexports nothing, and the SDK imports its modules. It keeps the operation registry, where a client looks up serialization contexts.index.ts, and each top-level declaration is@internal, sostripInternaldrops it from the published types.internalin place ofpublic. Its members stay public, so they are internal through their type. The SDK's tests see the types throughInternalsVisibleTo.internal/directory, Go's own rule.nexgen refuses arguments on the directive.
A new sample,
internal-service, shows it in the four languages, and it stays after the stream samples change. The stream sample's writer is internal too, so its tests import the service object from its module.It sits on #335. The stack is #308, #310, #311, #297, #296, #303, #304, #309, #318, #319, #320, #321, #322, #323, #324, #325, #326, #327, #328, #329, #330, #331, #332, #333, #334, #335, then this PR.
Why?
Brook's writer is a service of the SDK's runtime, not of its users. The generated packages export it next to the Stream API today, and the published TypeScript and .NET types show it.
The design also renamed the Python modules with a leading underscore (
_client.py,_models.py). This PR keeps their names, since the generated imports and the imports between packages name them, and sdk-python puts the package under its private_streamspackage already.The .NET tests of the samples compile their own copy of the internal package, since
InternalsVisibleToon the samples' project would also expose the internal support helpers, which the tests compile too.How did you test it?
A Python test checks that the internal package exports nothing, and calls its operation through its module. A TypeScript test calls the operation through its module and checks that the package has no
index.ts. A .NET compile check calls the internal operation. A Java test checks the warning, a unit test checks the directive, and a rejection fixture covers the refusal.cargo validatepasses.