-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #209 from perfectsense/feature/pubsub
Implement Pubsub resources
- Loading branch information
Showing
21 changed files
with
2,070 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
google::topic topic-example-for-snapshot | ||
name: "topic-example-for-snapshot" | ||
|
||
labels: { | ||
name: "topic-example-for-snapshot" | ||
} | ||
end | ||
|
||
google::subscription subscription-push-example | ||
name: "subscription-push-example-for-snapshot" | ||
topic: $(google::topic topic-example-for-snapshot) | ||
|
||
ack-deadline-seconds: 10 | ||
enable-message-ordering: false | ||
filter: "" | ||
retain-acked-messages: true | ||
|
||
dead-letter-policy | ||
dead-letter-topic: $(google::topic topic-example-for-snapshot) | ||
max-delivery-attempts: 5 | ||
end | ||
|
||
expiration-policy | ||
ttl | ||
seconds: 604800 | ||
nanos: 0 | ||
end | ||
end | ||
|
||
retry-policy | ||
maximum-backoff | ||
seconds: 600 | ||
nanos: 0 | ||
end | ||
|
||
minimum-backoff | ||
seconds: 600 | ||
nanos: 0 | ||
end | ||
end | ||
|
||
message-retention | ||
seconds: 604800 | ||
nanos: 0 | ||
end | ||
|
||
push-config | ||
push-endpoint: "https://google.com" | ||
end | ||
|
||
labels: { | ||
name: "subscription-push-example-for-snapshot" | ||
} | ||
end | ||
|
||
google::snapshot example-snapshot | ||
name: "example-snapshot" | ||
subscription: $(google::subscription subscription-push-example) | ||
|
||
labels: { | ||
name: "example-snapshot" | ||
} | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
google::topic topic-example-for-subscription | ||
name: "topic-example-for-subscription" | ||
|
||
labels: { | ||
name: "topic-example-for-subscription" | ||
} | ||
end | ||
|
||
google::subscription subscription-pull-example | ||
name: "subscription-pull-example" | ||
topic: $(google::topic topic-example-for-subscription) | ||
|
||
ack-deadline-seconds: 15 | ||
enable-message-ordering: false | ||
filter: "" | ||
retain-acked-messages: false | ||
|
||
expiration-policy | ||
ttl | ||
seconds: 2678400 | ||
nanos: 0 | ||
end | ||
end | ||
|
||
message-retention | ||
seconds: 525780 | ||
nanos: 0 | ||
end | ||
|
||
retry-policy | ||
maximum-backoff | ||
seconds: 600 | ||
nanos: 0 | ||
end | ||
|
||
minimum-backoff | ||
seconds: 600 | ||
nanos: 0 | ||
end | ||
end | ||
|
||
labels: { | ||
name: "subscription-pull-example" | ||
} | ||
end | ||
|
||
google::subscription subscription-push-example | ||
name: "subscription-push-example" | ||
topic: $(google::topic topic-example-for-subscription) | ||
|
||
ack-deadline-seconds: 10 | ||
enable-message-ordering: false | ||
filter: "" | ||
retain-acked-messages: true | ||
|
||
dead-letter-policy | ||
dead-letter-topic: $(google::topic topic-example-for-subscription) | ||
max-delivery-attempts: 5 | ||
end | ||
|
||
expiration-policy | ||
ttl | ||
seconds: 604800 | ||
nanos: 0 | ||
end | ||
end | ||
|
||
retry-policy | ||
maximum-backoff | ||
seconds: 600 | ||
nanos: 0 | ||
end | ||
|
||
minimum-backoff | ||
seconds: 600 | ||
nanos: 0 | ||
end | ||
end | ||
|
||
message-retention | ||
seconds: 604800 | ||
nanos: 0 | ||
end | ||
|
||
push-config | ||
push-endpoint: "https://google.com" | ||
end | ||
|
||
labels: { | ||
name: "subscription-push-example" | ||
} | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
google::topic topic-example | ||
name: "topic-example" | ||
|
||
labels: { | ||
name: "topic-example" | ||
} | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright 2021, Brightspot. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package gyro.google.pubsub; | ||
|
||
import gyro.core.resource.Diffable; | ||
import gyro.core.resource.Updatable; | ||
import gyro.core.validation.Range; | ||
import gyro.core.validation.Required; | ||
import gyro.google.Copyable; | ||
|
||
public class DeadLetterPolicy extends Diffable implements Copyable<com.google.pubsub.v1.DeadLetterPolicy> { | ||
|
||
private TopicResource deadLetterTopic; | ||
private Integer maxDeliveryAttempts; | ||
|
||
/** | ||
* The topic to which dead letter messages should be published. | ||
*/ | ||
@Required | ||
@Updatable | ||
public TopicResource getDeadLetterTopic() { | ||
return deadLetterTopic; | ||
} | ||
|
||
public void setDeadLetterTopic(TopicResource deadLetterTopic) { | ||
this.deadLetterTopic = deadLetterTopic; | ||
} | ||
|
||
/** | ||
* The maximum number of delivery attempts for any message. | ||
*/ | ||
@Required | ||
@Updatable | ||
@Range(min = 5, max = 100) | ||
public Integer getMaxDeliveryAttempts() { | ||
return maxDeliveryAttempts; | ||
} | ||
|
||
public void setMaxDeliveryAttempts(Integer maxDeliveryAttempts) { | ||
this.maxDeliveryAttempts = maxDeliveryAttempts; | ||
} | ||
|
||
@Override | ||
public String primaryKey() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public void copyFrom(com.google.pubsub.v1.DeadLetterPolicy model) throws Exception { | ||
setDeadLetterTopic(findById(TopicResource.class, model.getDeadLetterTopic())); | ||
setMaxDeliveryAttempts(model.getMaxDeliveryAttempts()); | ||
} | ||
|
||
com.google.pubsub.v1.DeadLetterPolicy toDeadLetterPolicy() { | ||
return com.google.pubsub.v1.DeadLetterPolicy.newBuilder() | ||
.setDeadLetterTopic(getDeadLetterTopic().getReferenceName()) | ||
.setMaxDeliveryAttempts(getMaxDeliveryAttempts()) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.