Skip to content

Conversation

jabubake
Copy link
Contributor

@jabubake jabubake commented Apr 6, 2017

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 jabubake requested a review from frankyn April 6, 2017 04:58
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 6, 2017
@lesv
Copy link
Contributor

lesv commented Apr 6, 2017

@jabubake Circle failed :(

Copy link
Contributor

@frankyn frankyn left a comment

Choose a reason for hiding this comment

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

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
Contributor

Choose a reason for hiding this comment

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

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
Contributor

Choose a reason for hiding this comment

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

500 -> HttpServletResponse.SC_INTERNAL_SERVER_ERROR


# [START env_variables]
env_variables:
PUBSUB_TOPIC: test-topic-1
Copy link
Contributor

Choose a reason for hiding this comment

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

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
Contributor

Choose a reason for hiding this comment

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

What does the '3' represent?

## Run

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

Choose a reason for hiding this comment

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

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

private static final PubSubService INSTANCE;

static {
System.out.println("instance");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this line necessary?

private static class LazyInit {
private static final PubSubService INSTANCE;

static {
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

@@ -0,0 +1,114 @@
<!--
Copyright 2016 Google Inc. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

New sample change year to 2016.

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

Choose a reason for hiding this comment

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

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
Contributor

Choose a reason for hiding this comment

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

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

@codecov-io
Copy link

codecov-io commented Apr 20, 2017

Codecov Report

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

Impacted file tree graph

@@            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.

Copy link
Contributor

@frankyn frankyn left a comment

Choose a reason for hiding this comment

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

Looking good! I have a few minor nits.


## Deploy

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

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

<%= PubSubHome.getReceivedMessages() %>
</table>
</body>
</html>
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a new line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

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

Choose a reason for hiding this comment

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

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
Contributor Author

Choose a reason for hiding this comment

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

Done.

}
}

// ...
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you add this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

</parent>

<properties>
<appengine.maven.plugin>1.0.0</appengine.maven.plugin>
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, done.

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

Choose a reason for hiding this comment

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

Cleaner solution 👍

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Clean up whitespace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

</plugins>
</build>
</project>
<!-- [END project] -->
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a new line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


## Setup

Make sure `gcloud` is installed and authenticated.
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

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
Contributor

Choose a reason for hiding this comment

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

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
Contributor Author

Choose a reason for hiding this comment

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

Done. That does sound better.

Copy link
Contributor

@frankyn frankyn left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@jabubake jabubake merged commit 4514e8b into master Apr 25, 2017
@jabubake jabubake deleted the pubsub-flexible-sample branch April 25, 2017 22:55
bourgeoisor 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).
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