Skip to content

Commit

Permalink
Add support for PubSub emulator host variable
Browse files Browse the repository at this point in the history
  • Loading branch information
mziccard committed Oct 17, 2016
1 parent 513ca70 commit fc80c3e
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class PubSubOptions extends GrpcServiceOptions<PubSub, PubSubRpc, PubSubO
private static final long serialVersionUID = 5640180400046623305L;
private static final String PUBSUB_SCOPE = "https://www.googleapis.com/auth/pubsub";
private static final Set<String> SCOPES = ImmutableSet.of(PUBSUB_SCOPE);
private static final String EMULATOR_HOST_ENV_VAR = "PUBSUB_EMULATOR_HOST";
private static final String DEFAULT_HOST = PublisherSettings.getDefaultServiceAddress()
+ ':' + PublisherSettings.getDefaultServicePort();

Expand Down Expand Up @@ -66,7 +67,8 @@ public PubSubRpc create(PubSubOptions options) {

@Override
protected String defaultHost() {
return DEFAULT_HOST;
String host = System.getProperty(EMULATOR_HOST_ENV_VAR, System.getenv(EMULATOR_HOST_ENV_VAR));
return host != null ? host : DEFAULT_HOST;
}

public static class Builder extends
Expand Down

0 comments on commit fc80c3e

Please sign in to comment.