Skip to content

Commit 92be0b6

Browse files
committed
Add more info to event driven funcs
1 parent 1e3ef9c commit 92be0b6

File tree

1 file changed

+24
-6
lines changed
  • module7-cloud-computing/r4.1-cloud-functions

1 file changed

+24
-6
lines changed

module7-cloud-computing/r4.1-cloud-functions/README.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,38 @@ exports.date = functions.https.onRequest((req, res) => {
6666
});
6767
```
6868

69-
## Background Functions
69+
## Event-driven functions
70+
71+
An event-driven architecture uses events to trigger and communicate between decoupled services and is common in modern applications built with microservices. An event is a change in state, or an update, like an item being placed in a shopping cart on an e-commerce website. Events can either carry the state (the item purchased, its price, and a delivery address) or events can be identifiers (a notification that an order was shipped).
7072

71-
Before moving into background functions, we need to understand this term, Pub/Sub.
73+
Before moving deepter into Event-driven functions, we need to understand Pub/Sub.
7274

7375
Pub/Sub, which stands for Publisher/Subscriber, allows services to communicate asynchronously, with latencies on the order of 100 milliseconds.
7476

7577
Pub/Sub is used for streaming analytics and data integration pipelines to ingest and distribute data. It is equally effective as messaging-oriented middleware for service integration or as a queue to parallelize tasks.
7678

77-
<b>What is background functions?</b>
79+
Core concepts of Pub/Sub
80+
81+
- **Subscription:** A named resource representing the stream of messages from a single, specific topic, to be delivered to the subscribing application.
82+
- **Publisher:** An application that creates and sends messages to a topic(s).
83+
- **Subscriber:** An application with a subscription to a topic(s) to receive messages from it.
84+
85+
### Common Pub/Sub Use-Cases
86+
87+
1. Implementing Asynchronous Workflows: You can create an application that is used to place and process orders. This application will use a Pub/Sub topic, where the order would be placed and can be picked up by multiple workers for its processing. 2. Distributing Event Notifications
88+
89+
2. Distributing Event Notifications: You can create an application that has a module that handles new user registrations. This module will fetch the data from user-signups and send notifications whenever a new registration occurs. The other module of the application will subscribe to receive the notifications sent by the first module. 3. Refreshing a Distributed Cache
90+
91+
3. Refreshing a Distributed Cache: You can create an application that will be responsible for publishing invalidation events to update the primary keys of objects that have been altered. 4. Reliability Improvement
92+
93+
4. Reliability Improvement: You can create a service in one region/zone and operate it from multiple regions by subscribing to a topic common to all regions. This can be used for failure recoveries in specific regions.
94+
95+
## Background Functions
7896

7997
A background function is one type of event-driven function.
8098
You use background functions when you want to have your Cloud Function invoked indirectly in response to an event, such as a message on a Pub/Sub topic, a change in a Cloud Storage bucket, or a Firebase event.
8199

82-
Pub/Sub example
83-
84-
This example shows a Cloud Function triggered by Pub/Sub events. Every time a message is published to a Pub/Sub topic, the function is invoked, and a greeting using data derived from the message is written to the log
100+
This example shows a google Cloud Function triggered by Pub/Sub events. Every time a message is published to a Pub/Sub topic (eg. new user signs-in), the function is invoked, and a greeting using data derived from the message is written to the log
85101

86102
```js
87103
/**
@@ -109,3 +125,5 @@ exports.helloPubSub = (message, context) => {
109125
- https://cloud.google.com/functions
110126
- https://aws.amazon.com/blogs/aws/introducing-cloudfront-functions-run-your-code-at-the-edge-with-low-latency-at-any-scale/
111127
- https://github.com/firebase/functions-samples
128+
- https://blog.clairvoyantsoft.com/pub-sub-notifications-with-google-cloud-storage-events-6992ca829dd5
129+
- https://aws.amazon.com/event-driven-architecture/

0 commit comments

Comments
 (0)