Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
got hand edited pubsub to work
  • Loading branch information
andreamlin committed Jan 24, 2018
commit ca81036e9d178b6775c395c406cab75672b3bd41
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.BatchingCallSettings;
import com.google.api.gax.rpc.BatchingDescriptor;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
import com.google.api.gax.rpc.HeaderProvider;
import com.google.api.gax.rpc.NoHeaderProvider;
import com.google.api.gax.rpc.PagedCallSettings;
import com.google.api.gax.rpc.PagedListResponseFactory;
import com.google.api.gax.rpc.StatusCode;
import com.google.api.gax.rpc.StubSettings;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.api.gax.rpc.UnaryCallSettings;
import com.google.auth.Credentials;
Expand Down Expand Up @@ -193,8 +193,7 @@ private static class Builder extends ClientSettings.Builder {
private BatchingCallSettings.Builder<Integer, Integer> fakeMethodBatching;

private Builder() {
super((ClientContext) null);

super((StubSettings) null);
fakeMethodSimple = UnaryCallSettings.newUnaryCallSettingsBuilder();
fakePagedMethod = PagedCallSettings.newBuilder(fakePagedListResponseFactory);
fakeMethodBatching =
Expand Down
8 changes: 8 additions & 0 deletions gax/src/main/java/com/google/api/gax/rpc/ClientContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ public Builder toBuilder() {
* settings.
*/
public static ClientContext create(ClientSettings settings) throws IOException {
return create(settings.getStubSettings());
}

/**
* Instantiates the executor, credentials, and transport context based on the given client
* settings.
*/
public static ClientContext create(StubSettings settings) throws IOException {
ImmutableList.Builder<BackgroundResource> backgroundResources = ImmutableList.builder();

ExecutorProvider executorProvider = settings.getExecutorProvider();
Expand Down
14 changes: 7 additions & 7 deletions gax/src/main/java/com/google/api/gax/rpc/ClientSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,24 @@ protected Builder(ClientSettings settings) {
this.stubSettings = settings.stubSettings.toBuilder();
}

protected Builder(ClientContext clientContext) {
this.stubSettings = new StubSettings.Builder(clientContext);
}

/** Create a builder from a StubSettings object. */
protected Builder(StubSettings stubSettings) {
this.stubSettings = stubSettings.toBuilder();
protected Builder(StubSettings.Builder stubSettings) {
this.stubSettings = stubSettings;
}

protected Builder() {
this((ClientContext) null);
this((StubSettings.Builder) null);
}

@SuppressWarnings("unchecked")
protected B self() {
return (B) this;
}

protected StubSettings.Builder getStubSettings() {
return stubSettings;
}

/**
* Sets the ExecutorProvider to use for getting the executor to use for running asynchronous API
* call logic (such as retries and long-running operations), and also to pass to the transport
Expand Down
20 changes: 11 additions & 9 deletions gax/src/main/java/com/google/api/gax/rpc/StubSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
* <p>If no ExecutorProvider is set, then InstantiatingExecutorProvider will be used, which creates
* a default executor.
*/
public class StubSettings<SettingsT extends ClientSettings<SettingsT>> {
public abstract class StubSettings<SettingsT extends StubSettings<SettingsT>> {

private final ExecutorProvider executorProvider;
private final CredentialsProvider credentialsProvider;
Expand Down Expand Up @@ -116,12 +116,13 @@ public String toString() {
.toString();
}

public StubSettings.Builder toBuilder() {
return new Builder(this);
}
public abstract StubSettings.Builder toBuilder();
// {
// return new Builder(this);
// }

This comment was marked as spam.

This comment was marked as spam.


public static class Builder<
SettingsT extends ClientSettings<SettingsT>, B extends Builder<SettingsT, B>> {
public abstract static class Builder<
SettingsT extends StubSettings<SettingsT>, B extends Builder<SettingsT, B>> {

private ExecutorProvider executorProvider;
private CredentialsProvider credentialsProvider;
Expand Down Expand Up @@ -286,9 +287,10 @@ protected static void applyToAllUnaryMethods(
}
}

public <B extends ClientSettings<B>> StubSettings<B> build() throws IOException {
return new StubSettings<B>(this);
}
public abstract <B extends StubSettings<B>> StubSettings<B> build() throws IOException;
// {
// return new StubSettings<B>(this);
// }

This comment was marked as spam.

This comment was marked as spam.


public String toString() {
return MoreObjects.toStringHelper(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.google.api.core.InternalApi;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
import com.google.api.gax.rpc.StubSettings;
import java.io.IOException;

@InternalApi("for testing")
Expand All @@ -53,11 +54,15 @@ public Builder(ClientSettings settings) {
}

public Builder(ClientContext clientContext) {
super(clientContext);
super(new FakeStubSettings.Builder(clientContext));
}

public Builder(StubSettings stubSettings) {
super(stubSettings.toBuilder());
}

public Builder() {
super((ClientContext) null);
super(new FakeStubSettings.Builder());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2017, Google LLC All rights reserved.

This comment was marked as spam.

This comment was marked as spam.

*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google LLC nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.google.api.gax.rpc.testing;

import com.google.api.core.InternalApi;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.StubSettings;
import java.io.IOException;

@InternalApi("for testing")
public class FakeStubSettings extends StubSettings {

private FakeStubSettings(Builder builder) throws IOException {
super(builder);
}

@Override
public StubSettings.Builder toBuilder() {
return new Builder(this);
}

public static class Builder extends StubSettings.Builder {

public Builder(ClientContext clientContext) {
super(clientContext);
}

public Builder(StubSettings stubSettings) {
super(stubSettings);
}

public Builder() {
super((ClientContext) null);
}

@Override
public com.google.api.gax.rpc.testing.FakeStubSettings build() throws IOException {
return new com.google.api.gax.rpc.testing.FakeStubSettings(this);
}
}
}