Skip to content

Commit

Permalink
fix(echo): Add default twilio API endpoint (#873)
Browse files Browse the repository at this point in the history
* fix(echo): Add default twilio API endpoint

Currently halyard is explicitly setting this default; instead of
having kleat need to know about this, just have it defaulted in
echo if kleat doesn't pass anything along. (This won't break any
existing config as Halyard is always passing this, so we'll never
fall to the default, and if anyone is overriding it that will still
be respected.)

* refactor(pubsub): Minor pubsub code cleanup

While reading through this code to document the config for kleat,
I made a few changes to improve it:
* As I traced everywhere we pass ackDeadlineSeconds, I changed it from
a NonNull Integer to an int
* Added an explicit type on a map to fix a compiler warning
  • Loading branch information
ezimanyi committed Apr 23, 2020
1 parent a74933c commit 27ce07b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class MessageDescription {

private PubsubSystem pubsubSystem;

private Integer ackDeadlineSeconds;
private int ackDeadlineSeconds;

private Integer retentionDeadlineSeconds;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import retrofit.converter.JacksonConverter
class TwilioConfig {

@Bean
Endpoint twilioEndpoint(@Value('${twilio.base-url}') String twilioBaseUrl) {
Endpoint twilioEndpoint(@Value('${twilio.base-url:https://api.twilio.com/}') String twilioBaseUrl) {
newFixedEndpoint(twilioBaseUrl)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void handleMessage(

private boolean tryAck(
String messageKey,
Integer ackDeadlineSeconds,
int ackDeadlineSeconds,
MessageAcknowledger acknowledger,
String identifier) {
if (!acquireMessageLock(messageKey, identifier, ackDeadlineSeconds)) {
Expand All @@ -124,8 +124,7 @@ private boolean tryAck(
}
}

private Boolean acquireMessageLock(
String messageKey, String identifier, Integer ackDeadlineSeconds) {
private boolean acquireMessageLock(String messageKey, String identifier, int ackDeadlineSeconds) {
String response =
redisClientDelegate.withCommandsClient(
c -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand Down Expand Up @@ -55,7 +54,7 @@ public static class GooglePubsubSubscription {

@NotEmpty private String subscriptionName;

@NotNull @Builder.Default private Integer ackDeadlineSeconds = 10;
@Builder.Default private int ackDeadlineSeconds = 10;

// Not required since subscriptions can be public.
private String jsonPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private void restart() {

private static class GooglePubsubMessageReceiver implements MessageReceiver {

private Integer ackDeadlineSeconds;
private int ackDeadlineSeconds;

private PubsubMessageHandler pubsubMessageHandler;

Expand All @@ -161,7 +161,7 @@ private static class GooglePubsubMessageReceiver implements MessageReceiver {
private NodeIdentity identity = new NodeIdentity();

public GooglePubsubMessageReceiver(
Integer ackDeadlineSeconds,
int ackDeadlineSeconds,
String subscriptionName,
PubsubMessageHandler pubsubMessageHandler) {
this.ackDeadlineSeconds = ackDeadlineSeconds;
Expand All @@ -173,7 +173,7 @@ public GooglePubsubMessageReceiver(
public void receiveMessage(PubsubMessage message, AckReplyConsumer consumer) {
String messagePayload = message.getData().toStringUtf8();
String messageId = message.getMessageId();
Map messageAttributes =
Map<String, String> messageAttributes =
message.getAttributesMap() == null ? new HashMap<>() : message.getAttributesMap();
log.debug(
"Received Google pub/sub message with payload: {}\n and attributes: {}",
Expand Down

0 comments on commit 27ce07b

Please sign in to comment.