The workflow is triggered each 5 minutes and retrieves the worth of the present consumer counter from a Firestore database utilizing the Firestore Connector. Together with the counter worth, it additionally retrieves the final state of the site visitors, e.g., “Low”, “Normal”, “High”, that was saved through the workflow’s  earlier run. 

Workflows’ built-in switch step, mixed with a customized method, is used to find out whether or not the present worth of the counter would make it fall to a unique state than the one saved within the earlier run of the workflow. If that’s the case, the brand new state is saved within the Firestore database and  Pub/Sub Connector pushes a message to the assist staff, informing them about state change. The workflow is checking not solely the present worth of the counter but additionally the final recorded state, in order that solely standing adjustments lead to notifications. 

With only some steps, the workflow above turns into a dependable serverless software with full monitoring of execution historical past. Constructed-in Identity and Access Management (IAM) integration reduces the complexity of interacting with different Google Cloud merchandise, like Firestore or Pub/Sub.

Learn to schedule workflow executions utilizing Cloud Scheduler, just like the instance above, in this guide.

Workflows with API polling 

Contemplate a workflow that requests an execution of a long-running job utilizing an exterior API. The exterior API accepts a job execution request and returns a singular JobID that can be utilized to ballot for this job’s execution standing. The job can take hours and the workflow can solely proceed to the subsequent steps solely as soon as this job is accomplished. As there is no such thing as a characteristic on this API to inform the workflow a few job completion, the workflow must periodically ballot for the job standing.

The workflow introduced beneath implements this sample, checking the standing of the job each 2 minutes. Word that Workflows’ pricing mannequin is predicated on the variety of executed steps and there’s no time-related cost for a sleep operation. Workflows can run for as much as a yr, so that you could be assured that they may comply with via on even the longest-running jobs.



Leave a Reply

Your email address will not be published. Required fields are marked *