Coder Social home page Coder Social logo

mikaelvesavuori / gcp-scheduled-job-demo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 2.0 875 KB

GCP Demo: Distributing a scheduled job over Cloud Scheduler and Cloud Tasks tasks

Shell 55.60% JavaScript 43.38% Dockerfile 1.02%
gcp google-cloud-platform cloud-tasks cloud-scheduler cloud-functions cloud-run demo

gcp-scheduled-job-demo's Introduction

GCP Demo: Distributing a scheduled job over Cloud Scheduler and Cloud Tasks tasks

This repo demonstrates how to:

  • Set up a scheduled activity (using Cloud Scheduler) that pulls data (an array of objects) from local data in a Cloud Function that offloads the data to a Pub/Sub topic...
  • Which in turn has a Cloud Function trigger on the topic; the function divides the retrieved data into individual Cloud Tasks, so that the individual pieces of data are handled uniquely, then...
  • Runs a service on Cloud Run to do something with the data from each individual task.
  • Bonus: Creating and using separate service accounts for each service and using a completely private setup.

GCP architecture map GCP logging output

Prerequisites

  • You have a GCP account
  • You are logged in through your environment
  • You have set your variables as needed in init.sh and the respective deploy.sh files

Instructions

Run locally

  • Install dependencies with npm install or yarn install.
  • Run npm start or yarn start
  • Call or visit endpoint; should be http://localhost:8080/

Deploy to GCP

First of all, go through all scripts with names like init.sh, deploy.sh and index.js and ensure you set any relevant values that you are asked for.

Run init.sh. You should run this in steps since some things need to be done dynamically (like adding IDs).

Functions will have deployment URLs in the format https://{REGION}-{PROJECT}.cloudfunctions.net/{FUNCTION}. You'll also get a unique URL to the Cloud Run service.

Where to find things

Logs are available in the Logs view or through the Functions view.

The Cloud Run service is available at the Services view.

Cloud Scheduler will display the job in the Jobs view. For the Cloud Tasks queue, it's visible at Queues, which is good to have a look at if your calls are getting stuck (i.e. not working as intended).

Remove resources

Run teardown.sh. This will destroy the entire project, so know what you are getting into!

References

gcp-scheduled-job-demo's People

Contributors

mikaelvesavuori avatar

Watchers

 avatar

Forkers

charan17k m4r1k

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.