GithubHelp home page GithubHelp logo

isabella232 / fun-with-temporal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from crawl-space/fun-with-temporal

0.0 0.0 0.0 63 KB

just having fun with temporal for no reason. none at all.

JavaScript 9.80% Go 87.41% Dockerfile 2.79%

fun-with-temporal's Introduction

Temporal Fun

This repo shows you some fun with temporal, running a workflow under temporal, but having the bulk of the work done by an external REST API that calls back when work is done.

The setup

  • You have an external system calling your API (say, a webhook that fires when new PRs are open). This is handled by the go worker's pr http handler.
  • Once the API is called, it enqueues a workflow run to deal with PRs. This is put in termporal.
  • worker process picks up this workflow run, and calls out to a leaf process that does the work. this is the node.js process in the leaf dir.
  • The leaf worker gets a callback url. When it's done (after 10 seconds) it calls back to complete the work.
  • The worker waits for two such jobs running in parallel, then does some extra work internally, then does some further external work (say, to set a commit status on the original PR). Then its done!

Temporal handles:

  • queueing and limiting the work after accepting that original /pr call
  • checkpointing steps in the workflow (in workflow/workflow.go) so that in the event of failure, work is not lost.
  • retries for any part of originally sending the work to the leaf, or if it does not call back (or heartbeat) before a dealine.

Run it

  • Run docker compose up -d to start temporal and the local services:
    • worker, the workflow runner and rest API
    • leaf, a leaf capability service

Now you're ready to enqueue work.

  • install httpie because it's really good and you deserve nice things. you do. it's ok to indulge once in a while in a nice CLI tool.
  • Set up some work! run http POST 127.0.0.1:6007/pr repo=jbowes/repl pr=123 old=bahbah new=naynay To simulate a PR against the jbowes/repl repo, with old and new SHASUMs.
  • Watch the output for the leaf process, as it gets requests, and sends completion information after 10 seconds.
  • Watch the worker process as it finishes jobs and tells you that it set a commit status.
  • Turn things off and on again and have fun.

fun-with-temporal's People

Contributors

jbowes avatar

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.