@simpleview/sv-pubsub 1.0.15 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -0
  3. package/package.json +1 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 simpleviewinc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # sv-pubsub-client
2
+
3
+ Client for communicating with the Google Pub/Sub service.
4
+
5
+ [Google Pub/Sub](https://docs.cloud.google.com/pubsub/docs/overview) is the message broker typically used by microservices to communicate events that occur in one system to the other. These events are typically changes in data, e.g. `accounts-update`.
6
+
7
+ The most important concepts in Google Pub/Sub are [Topics](https://docs.cloud.google.com/pubsub/docs/create-topic), [Subscriptions](https://docs.cloud.google.com/pubsub/docs/subscription-overview) and [Messages](https://docs.cloud.google.com/pubsub/docs/publisher).
8
+
9
+ Publishing a Message to a Topic without any Subscriptions will result in that message being lost.
10
+ A Topic can and should be created by both Producers and Consumers of that Topic, to ensure that it exists before either end attempt to interact with it.
11
+ Subscriptions are created from Topics.
12
+
13
+ These hold Messages, which Consumers consume via the persistent bidirectional connection it maintains with the Google Pub/Sub service. This is called a "streaming pull", not to be confused with polling/pull, which relies on the Consumer polling for new Messages on an interval.
14
+
15
+ ## Publish and Subscribe Architecture
16
+
17
+ Google Pub/Sub supports [several architecture patterns](https://docs.cloud.google.com/pubsub/docs/pubsub-basics#choose_a_publish_and_subscribe_pattern), i.e. configurations of producers, topics, subscriptions and consumers, allowing you to achieve different results:
18
+ - **Fan in (many-to-one):** This setup allows you to make a consumer aware events that may originate in multiple systems. E.g. you have a web app, a mobile app and a partner API that can all trigger an `accounts-update` event. This is achieved by having many producers publishing to a single topic, the topic is connected to a single subscription, which, in turn, a single consumer will consume events from.
19
+ - **Fan out (one-to-many):** You want a particular event that's been triggered by one or more producers to be published to a single topic. Multiple subscriptions are created from that topic, and each subscription has a copy of the event, which is intended for a different handler. E.g. A user archives an account in a source system, that's broadcasted through a single topic, which is connected to multiple subscriptions. This allows each subscription to be dedicated to a single purpose, allowing consumers of each subscription to perform the necessary updates/cleanup associated with that subscription.
20
+ - **Load balanced (many-to-many):** One or more producers publish an event to a single topic. All consumers should attempt to create a subscription from this topic, then each consumer attaches a handler to this subscription. The Google Pub/Sub service then decides which consumer gets forwarded the message, which the consumer must handle and send an acknowledgement back to the service. Unacknowledged events will eventually time out and be lost. An example of this would be when there's a high throughput of events, and handling them requires multiple consumers.
21
+
22
+ ## Authorising with Google Pub/Sub
23
+
24
+ Authorisation should be done through service accounts. Each microservice typically has a service account. A service account will need permissions to create topics, subscriptions, attach to subscriptions and publish messages in order to authorise.
25
+
26
+ The credentials required are:
27
+ - `projectId`, e.g. **sv-shared-231700**
28
+ - `credentials`, i.e. the Application Default Credentials of your Google Service Account
29
+
30
+ ## Conventions
31
+
32
+ Topics should be named after the environment, producer, and event name of the events that pass through it.
33
+ For example, if a Camber user updates an Account on the live app, we would be broadcasting that events to all Consumers of a Topic named `live-camber-accounts-updated`.
34
+
35
+ Subscriptions should be named after the consuming app, e.g. `live-auth-live-camber-accounts-updated` and set an appropriate retention period. Subscriptions are never automatically cleaned up, however the Messages stored within them are deleted after an hour, by default, although this can be changed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpleview/sv-pubsub",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "Client for communicating with Google Pub/Sub",
5
5
  "author": "Paul Riding <paul.riding@granicus.com>",
6
6
  "devDependencies": {