Giter Site home page Giter Site logo

sagikazarmark / temporal-intro-workshop Goto Github PK

View Code? Open in Web Editor NEW
30.0 3.0 8.0 4.08 MB

Temporal intro workshop

Home Page: https://sagikazarmark.github.io/temporal-intro-workshop/

License: MIT License

Makefile 7.85% Go 50.17% Nix 3.89% CSS 28.60% HTML 9.48%
golang go temporal workshop hacktoberfest

temporal-intro-workshop's Introduction

Temporal Intro Workshop

This repository contains example code for my Temporal Intro Workshop. You can create your own Workshop with my Workshop template.

Record: https://youtu.be/UwdGmdTO3Ts

Record (HUN): https://youtu.be/IGAnWQ52xOI

Prerequisites

  1. Git, Make, etc.
  2. Make sure you have the latest Go and Docker installed

Alternatively, install nix and direnv, then run direnv allow once you checked out the repository.

Note: you should still install Docker using your native package manager.

Usage

  1. Checkout this repository
  2. Run make up
  3. Wait for Temporal to start
  4. Check if Temporal is running with make ps
  5. Start a new shell with make shell

Alternatively, you can use the following alias for the tctl commands instead of opening a new shell:

alias tctl='docker compose exec --profile cli temporal-admin-tools tctl'

Running a workflow using the CLI

You can run a workflow using the CLI with the following command:

tctl workflow run --taskqueue workshop --execution_timeout 60 --workflow_type WORKFLOW_TYPE -i 'arg1 arg2...'

As a best practice, workflows generally have a single input struct (to remain compatible with other languages). By default, Temporal uses JSON encoding, so such workflow execution looks like this:

tctl workflow run --taskqueue workshop --execution_timeout 60 --workflow_type example01 -i '{"A": 1, "B": 2}'

You can shorten the command a lot by using shorthands for commands and options:

tctl wf run --tq workshop --et 60 --wt example01 -i '{"A": 1, "B": 2}'

Last, but not least, if you want to start a workflow without waiting for its result, you can do so by using the start command instead of run:

tctl wf start --tq workshop --et 60 --wt example01 -i '{"A": 1, "B": 2}'

Quering workflow state using the CLI

Workflows can register query handlers to expose state about themselves. You can query that state using the following command:

tctl workflow query --workflow_id 72daa600-3cac-49b0-9e86-277a47c80a87 --query_type current_number

Or using a shorter version:

tctl wf query --wid 72daa600-3cac-49b0-9e86-277a47c80a87 --qt current_number

There is a special query type called __stack_trace that gives you the current stack trace of the workflow. Useful if a workflow is stuck for a long time and you want to check where it stopped.

Signaling a workflow using the CLI

Workflows can register query handlers to expose state about themselves. You can query that state using the following command:

tctl workflow signal --workflow_id 72daa600-3cac-49b0-9e86-277a47c80a87 --name set_number --input '2'

Or using a shorter version:

tctl wf signal --wid 72daa600-3cac-49b0-9e86-277a47c80a87 -n set_number -i '2'

There is a special query type called __stack_trace that gives you the current stack trace of the workflow. Useful if a workflow is stuck for a long time and you want to check where it stopped.

Cleaning up

Once you are finished with the workshop, you can clean up all resources (containers) by running the following command:

make down

Development

Make sure nix and direnv are installed, then run direnv allow.

To work on the slides, run make slides. It will open a browser window and automatically refresh the page when you make changes to the slides.

License

The MIT License (MIT). Please see License File for more information.

temporal-intro-workshop's People

Contributors

dependabot[bot] avatar sagikazarmark avatar swyxio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

temporal-intro-workshop's Issues

PRs welcome?

Hey, this is a really great resource and I'm learning a lot with it. Just curious if you'd like PRs? Seems like there have been some changes since last year and it might be cool to keep this up to date for other folks to reference.

I haven't been through everything yet but one thing I've noticed is that the client.NewClient() is now deprecated, in favor of either client.Dial() or client.NewLazyClient(), according to package docs.

Happy to contribute if the value/desire is there.

Cheers!

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.