FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Pubsub flexible sample by jabubake · Pull Request #592 · GoogleCloudPlatform/java-docs-samples · GitHub

Pubsub flexible sample - #592

Merged
jabubake merged 27 commits into
masterfrom
pubsub-flexible-sample
Apr 25, 2017
Merged

Pubsub flexible sample#592
jabubake merged 27 commits into
masterfrom
pubsub-flexible-sample

Conversation

jabubake commented Apr 6, 2017

Copy link
Copy Markdown
Contributor

Flex pubsub push endpoint sample with Datastore persistence.
Tests : TODO (given we're consolidating the flex apps for testing, removed the existing ones for now for this sample)

jabubake requested a review from frankyn April 6, 2017 04:58
googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 6, 2017

lesv commented Apr 6, 2017

Copy link
Copy Markdown
Contributor

@jabubake Circle failed :(

frankyn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Overall, it's looking great. I commented on a few things.

  1. Style check failed in CircleCI
  2. The sample is missing tests.

try {
messageRepository.save(message);
// 200, 201, 204, 102 status codes are interpreted as success by the Pub/Sub system
resp.setStatus(200);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

200 -> HttpServletResponse.SC_OK

// 200, 201, 204, 102 status codes are interpreted as success by the Pub/Sub system
resp.setStatus(200);
} catch (Exception e) {
resp.setStatus(500);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

500 -> HttpServletResponse.SC_INTERNAL_SERVER_ERROR


# [START env_variables]
env_variables:
PUBSUB_TOPIC: test-topic-1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The values should reflect the README for this sample.
export PUBSUB_TOPIC=
export PUBSUB_VERIFICATION_TOKEN=
export PUBSUB_SUBSCRIPTION_ID=

try (SubscriptionAdminClient subscriberAdminClient = SubscriptionAdminClient.create()) {
try {
subscriberAdminClient.createSubscription(
subscriptionName, getTopicName(topicId), pushConfig, 3);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What does the '3' represent?

Comment thread flexible/pubsub/README.md Outdated
## Run

Set the following environment variables and run using shown Maven command. You can then
direct your browser to `http://localhost:8080/`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Double space next to "browser to[SPACE][SPACE]"

private static final PubSubService INSTANCE;

static {
System.out.println("instance");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is this line necessary?

private static class LazyInit {
private static final PubSubService INSTANCE;

static {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

After reading into this Lazy initialization singleton pattern. I wonder if there's a more readable solution? This wasn't clear during my first pass.

Comment thread flexible/pubsub/pom.xml Outdated
@@ -0,0 +1,114 @@
<!--
Copyright 2016 Google Inc. All Rights Reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

New sample change year to 2016.

// Get Message saved in Datastore
Datastore datastore = getDatastoreInstance();
Query<Entity> query =
Query.newEntityQueryBuilder()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This should fit in the previous line.

* @param endpoint push endpoint URL
* @throws Exception
*/
private void addPushEndPoint(String topicId, String subscriptionId, String endpoint)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This method wasn't easy to read. Can you make this method be more descriptive?

codecov-io commented Apr 20, 2017
edited
Loading

Copy link
Copy Markdown

Codecov Report

Merging #592 into master will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master     #592   +/-   ##
=========================================
  Coverage     55.84%   55.84%           
  Complexity      202      202           
=========================================
  Files            74       74           
  Lines          2052     2052           
  Branches        131      131           
=========================================
  Hits           1146     1146           
  Misses          874      874           
  Partials         32       32

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 5b63acb...7256754. Read the comment docs.

frankyn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looking good! I have a few minor nits.

Comment thread flexible/pubsub/README.md Outdated

## Deploy

Update the environment variables `PUBSUB_TOPIC` and `PUBSUB_VERIFICATION_TOKEN` in `app.yaml`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

provide a link to the app.yaml or a full path. src/main/appengine/app.yaml

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done.

<%= PubSubHome.getReceivedMessages() %>
</table>
</body>
</html> No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Add a new line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done.

@@ -0,0 +1,21 @@
<%@ page import="com.example.flexible.pubsub.PubSubHome" %>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

One thing I noticed is, I had to refresh the page to see an updated list of messages. What do you think about adding an auto-refresh every 10 seconds or so?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done.

}
}

// ...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why did you add this line?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I was trying to show that it was an incomplete class but it seems useless, removed.

Comment thread flexible/pubsub/pom.xml Outdated
</parent>

<properties>
<appengine.maven.plugin>1.0.0</appengine.maven.plugin>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm sure this will be auto-updated once merged, but this version has updated to 1.3.0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Good catch, done.

*
* @return html representation of messages (one per row)
*/
public static String getReceivedMessages() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Cleaner solution 👍

*/
List<Message> retrieve(int limit);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Clean up whitespace

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done.

Comment thread flexible/pubsub/pom.xml Outdated
</plugins>
</build>
</project>
<!-- [END project] --> No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Add a new line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

done

Comment thread flexible/pubsub/README.md Outdated

## Setup

Make sure `gcloud` is installed and authenticated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Add a link to Cloud SDK https://cloud.google.com/sdk/docs/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done.

Comment thread flexible/pubsub/README.md Outdated
gcloud beta pubsub topics create <your-topic-name>
```

Create a subscription, which includes specifying the endpoint to which the Pub/Sub server should send requests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Maybe change this to:

Create a push subscription, to send pushed messages to a Google Cloud Project URL such as https://<your-project-id>.appspot.com/.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done. That does sound better.

frankyn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM, thanks!

jabubake merged commit 4514e8b into master Apr 25, 2017
jabubake deleted the pubsub-flexible-sample branch April 25, 2017 22:55
olivi-eh pushed a commit that referenced this pull request Nov 11, 2022
…3.0 (#592)

[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.cloud:libraries-bom](https://cloud.google.com/java/docs/bom) ([source](https://togithub.com/GoogleCloudPlatform/cloud-opensource-java)) | `25.2.0` -> `25.3.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/25.3.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/25.3.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/25.3.0/compatibility-slim/25.2.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/25.3.0/confidence-slim/25.2.0)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-notification).
This file contains hidden or 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL