Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Update google api header#179

Merged
shinfan merged 10 commits intogoogleapis:masterfrom
shinfan:master
Feb 9, 2017
Merged

Update google api header#179
shinfan merged 10 commits intogoogleapis:masterfrom
shinfan:master

Conversation

@shinfan
Copy link
Contributor

@shinfan shinfan commented Jan 23, 2017

Now the gapic header has the following format:
Gapic only client: gl-java/{java_version} gapic/0.1.0 gax/0.0.27 grpc/1.0.1
Hand-written client: gl-java/{java_version} gccl/0.0.0 gapic/0.1.0 gax/0.0.27 grpc/1.0.1

The hand-written layer can override the top level token 'gapic/0.1.0' by setting the client name/version.

  • Add unit test

@codecov-io
Copy link

codecov-io commented Jan 23, 2017

Codecov Report

Merging #179 into master will increase coverage by 0.34%.

@@             Coverage Diff              @@
##             master     #179      +/-   ##
============================================
+ Coverage     70.04%   70.38%   +0.34%     
- Complexity      460      463       +3     
============================================
  Files            64       64              
  Lines          2420     2418       -2     
  Branches        260      262       +2     
============================================
+ Hits           1695     1702       +7     
+ Misses          631      620      -11     
- Partials         94       96       +2
Impacted Files Coverage Δ Complexity Δ
...gle/api/gax/grpc/InstantiatingChannelProvider.java 53.16% <65.21%> (+9.95%) 10 <4> (+3)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a0f5b1b...69aa90a. Read the comment docs.

*/
public final class InstantiatingChannelProvider implements ChannelProvider {
private static final String DEFAULT_GAX_VERSION = "0.0.27";
private static final String DEFAULT_GRPC_VERSION = "1.0.1";

This comment was marked as spam.

This comment was marked as spam.

"%s/%s %s/%s gax/%s java/%s",
clientLibName,
clientLibVersion,
"%s/%s gax/%s grpc/%s java/%s",

This comment was marked as spam.

This comment was marked as spam.

// Default names and versions of the client and the service generator.
private static final String DEFAULT_GENERATOR_NAME = "gapic";
private static final String DEFAULT_CLIENT_LIB_NAME = "gax";
private static final String DEFAULT_CLIENT_LIB_NAME = "default";

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

String.format(
"gapic/0.1.0 gax/0.0.27 grpc/1.0.1 java/%s default/0.1.0",
Runtime.class.getPackage().getImplementationVersion());
assertEquals(provider.serviceHeader(), expectedHeader);

This comment was marked as spam.

This comment was marked as spam.

@bjwatson bjwatson self-requested a review January 26, 2017 21:15
@bjwatson
Copy link

I'll review this soon. The design doc is not fully baked, since there are still a few unresolved concerns.

@shinfan
Copy link
Contributor Author

shinfan commented Feb 8, 2017

@bjwatson Friendly ping~

@bjwatson
Copy link

bjwatson commented Feb 8, 2017

Thanks for the updates @shinfan. I'm reviewing now.

*/
public final class InstantiatingChannelProvider implements ChannelProvider {
private static final String DEFAULT_GAX_VERSION = "UNKNOWN";
private static final String DEFAULT_GRPC_VERSION = "1.0.1";

This comment was marked as spam.

// Default names and versions of the client and the service generator.
private static final String DEFAULT_GENERATOR_NAME = "gapic";
private static final String DEFAULT_CLIENT_LIB_NAME = "gax";
private static final String DEFAULT_CLIENT_LIB_NAME = "default";

This comment was marked as spam.

Copy link

@bjwatson bjwatson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good. We might move gl-java to the beginning of the list (see the email thread today). I just have a few requested changes, and want to confirm that corresponding toolkit changes are also needed.

@@ -159,6 +150,22 @@ public boolean shouldAutoClose() {
}

@VisibleForTesting

This comment was marked as spam.

This comment was marked as spam.

@RunWith(JUnit4.class)
public class InstantiatingChannelProviderTest {

@Test

This comment was marked as spam.

This comment was marked as spam.

this.serviceGeneratorName = name;
this.serviceGeneratorVersion = version;
/** Sets the generator name and version for the GRPC custom header. */
public Builder setClientHeader(String name, String version) {

This comment was marked as spam.

This comment was marked as spam.

String grpcVersion = ManagedChannel.class.getPackage().getImplementationVersion();
if (grpcVersion == null) {
grpcVersion = DEFAULT_GRPC_VERSION;
}

This comment was marked as spam.

This comment was marked as spam.

grpcVersion = DEFAULT_GRPC_VERSION;
}

String javaVersion = Runtime.class.getPackage().getImplementationVersion();

This comment was marked as spam.

This comment was marked as spam.

@shinfan
Copy link
Contributor Author

shinfan commented Feb 9, 2017

@bjwatson PTAL

@bjwatson
Copy link

bjwatson commented Feb 9, 2017

LGTM

String clientLibName,
String clientLibVersion,
String serviceGeneratorName,
String serviceGeneratorVersion) {

This comment was marked as spam.

@bjwatson
Copy link

bjwatson commented Feb 9, 2017 via email

@garrettjonesgoogle
Copy link
Member

Because the gccl version implies the gapic version for all source delivery languages. When you switch Datastore to use GAPIC, then you'll know the gccl version as of which that happened.

(Of course we'll need to keep track
of this somehow)

That's the part that concerns me. I don't want to track this.

You can add the gapic version to the header if you really want to, but be aware that you're adding some server overhead to every call without providing any additional information.

But it actually is additional information - information that is otherwise a chore to uncover, because it requires digging up old source code revisions to find it out. Think of this scenario: there could be cases where we regenerate some GAPIC clients but not others, and thus for a particular gccl version, the gapic version depends on the API.

@garrettjonesgoogle
Copy link
Member

Oh and I forgot to mention the scenario of an API starting with GAPIC-only, then converting to having a handwritten layer. In that case, the gapic version would disappear and there would be no continuity.

@shinfan
Copy link
Contributor Author

shinfan commented Feb 9, 2017

@garrettjonesgoogle PTAL

@garrettjonesgoogle
Copy link
Member

LGTM

@shinfan shinfan merged commit 6a4c211 into googleapis:master Feb 9, 2017
// Default names and versions of the client and the service generator.
// Default names and versions of the service generator.
private static final String DEFAULT_GENERATOR_NAME = "gapic";
private static final String DEFAULT_CLIENT_LIB_NAME = "gax";

This comment was marked as spam.

This comment was marked as spam.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants