chore: regen snippets (#2122)

This commit is contained in:
matt
2025-08-12 11:29:45 -04:00
committed by GitHub
parent 1eb1634093
commit 815a94e25c
464 changed files with 6248 additions and 32 deletions

View File

@@ -1,4 +1,4 @@
# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand.
# This file is automatically @generated by Poetry 2.0.0 and should not be changed by hand.
[[package]]
name = "aiohappyeyeballs"
@@ -114,7 +114,7 @@ propcache = ">=0.2.0"
yarl = ">=1.17.0,<2.0"
[package.extras]
speedups = ["Brotli ; platform_python_implementation == \"CPython\"", "aiodns (>=3.2.0) ; sys_platform == \"linux\" or sys_platform == \"darwin\"", "brotlicffi ; platform_python_implementation != \"CPython\""]
speedups = ["Brotli", "aiodns (>=3.2.0)", "brotlicffi"]
[[package]]
name = "aiohttp-retry"
@@ -199,12 +199,32 @@ files = [
]
[package.extras]
benchmark = ["cloudpickle ; platform_python_implementation == \"CPython\"", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pympler", "pytest (>=4.3.0)", "pytest-codspeed", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"]
cov = ["cloudpickle ; platform_python_implementation == \"CPython\"", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"]
dev = ["cloudpickle ; platform_python_implementation == \"CPython\"", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pre-commit-uv", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"]
benchmark = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-codspeed", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
cov = ["cloudpickle", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
dev = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pre-commit-uv", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
docs = ["cogapp", "furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier"]
tests = ["cloudpickle ; platform_python_implementation == \"CPython\"", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"]
tests-mypy = ["mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\""]
tests = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
tests-mypy = ["mypy (>=1.11.1)", "pytest-mypy-plugins"]
[[package]]
name = "cel-python"
version = "0.2.0"
description = "Pure Python implementation of Google Common Expression Language"
optional = false
python-versions = "<4.0,>=3.8"
groups = ["main"]
files = [
{file = "cel_python-0.2.0-py3-none-any.whl", hash = "sha256:478ff73def7b39d51e6982f95d937a57c2b088c491c578fe5cecdbd79f476f60"},
{file = "cel_python-0.2.0.tar.gz", hash = "sha256:75de72a5cf223ec690b236f0cc24da267219e667bd3e7f8f4f20595fcc1c0c0f"},
]
[package.dependencies]
jmespath = ">=1.0.1,<2.0.0"
lark = ">=0.12.0,<0.13.0"
python-dateutil = ">=2.9.0.post0,<3.0.0"
pyyaml = ">=6.0.1,<7.0.0"
types-python-dateutil = ">=2.9.0.20240316,<3.0.0.0"
types-pyyaml = ">=6.0.12.20240311,<7.0.0.0"
[[package]]
name = "frozenlist"
@@ -440,20 +460,21 @@ setuptools = "*"
[[package]]
name = "hatchet-sdk"
version = "1.17.0"
version = "1.0.0a1"
description = ""
optional = false
python-versions = "<4.0,>=3.10"
groups = ["main"]
files = [
{file = "hatchet_sdk-1.17.0-py3-none-any.whl", hash = "sha256:ff9c744abafaa0e218e618dfb1c80c88f355146cbb85fc4a08d8b109c601c8bb"},
{file = "hatchet_sdk-1.17.0.tar.gz", hash = "sha256:2f47791ec23ffd5637422c5879daba85fa834fd8d4effd0a4e4bf7c0bb9c4f12"},
{file = "hatchet_sdk-1.0.0a1-py3-none-any.whl", hash = "sha256:bfc84358c8842cecd0d95b30645109733b7292dff0db1a776ca862785ee93d7f"},
{file = "hatchet_sdk-1.0.0a1.tar.gz", hash = "sha256:f0272bbaac6faed75ff727826e9f7b1ac42ae597f9b590e14d392aada9c9692f"},
]
[package.dependencies]
aiohttp = ">=3.10.5,<4.0.0"
aiohttp-retry = ">=2.8.3,<3.0.0"
aiostream = ">=0.5.2,<0.6.0"
cel-python = ">=0.2.0,<0.3.0"
grpcio = [
{version = ">=1.64.1,<1.68.dev0 || >=1.69.dev0", markers = "python_version < \"3.13\""},
{version = ">=1.69.0", markers = "python_version >= \"3.13\""},
@@ -462,11 +483,13 @@ grpcio-tools = [
{version = ">=1.64.1,<1.68.dev0 || >=1.69.dev0", markers = "python_version < \"3.13\""},
{version = ">=1.69.0", markers = "python_version >= \"3.13\""},
]
prometheus-client = ">=0.21.1"
protobuf = ">=5.29.5,<6.0.0"
nest-asyncio = ">=1.6.0,<2.0.0"
prometheus-client = ">=0.21.1,<0.22.0"
protobuf = ">=5.29.1,<6.0.0"
pydantic = ">=2.6.3,<3.0.0"
pydantic-settings = ">=2.7.1,<3.0.0"
python-dateutil = ">=2.9.0.post0,<3.0.0"
pyyaml = ">=6.0.1,<7.0.0"
tenacity = ">=8.4.1"
urllib3 = ">=1.26.20"
@@ -488,6 +511,35 @@ files = [
[package.extras]
all = ["flake8 (>=7.1.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.6.2)"]
[[package]]
name = "jmespath"
version = "1.0.1"
description = "JSON Matching Expressions"
optional = false
python-versions = ">=3.7"
groups = ["main"]
files = [
{file = "jmespath-1.0.1-py3-none-any.whl", hash = "sha256:02e2e4cc71b5bcab88332eebf907519190dd9e6e82107fa7f83b1003a6252980"},
{file = "jmespath-1.0.1.tar.gz", hash = "sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe"},
]
[[package]]
name = "lark"
version = "0.12.0"
description = "a modern parsing library"
optional = false
python-versions = "*"
groups = ["main"]
files = [
{file = "lark-0.12.0-py2.py3-none-any.whl", hash = "sha256:ed1d891cbcf5151ead1c1d14663bf542443e579e63a76ae175b01b899bd854ca"},
{file = "lark-0.12.0.tar.gz", hash = "sha256:7da76fcfddadabbbbfd949bbae221efd33938451d90b1fefbbc423c3cccf48ef"},
]
[package.extras]
atomic-cache = ["atomicwrites"]
nearley = ["js2py"]
regex = ["regex"]
[[package]]
name = "multidict"
version = "6.2.0"
@@ -593,6 +645,18 @@ files = [
[package.dependencies]
typing-extensions = {version = ">=4.1.0", markers = "python_version < \"3.11\""}
[[package]]
name = "nest-asyncio"
version = "1.6.0"
description = "Patch asyncio to allow nested event loops"
optional = false
python-versions = ">=3.5"
groups = ["main"]
files = [
{file = "nest_asyncio-1.6.0-py3-none-any.whl", hash = "sha256:87af6efd6b5e897c81050477ef65c62e2b2f35d51703cae01aff2905b1852e1c"},
{file = "nest_asyncio-1.6.0.tar.gz", hash = "sha256:6f172d5449aca15afd6c646851f4e31e02c598d553a667e38cafa997cfec55fe"},
]
[[package]]
name = "prometheus-client"
version = "0.21.1"
@@ -718,23 +782,23 @@ files = [
[[package]]
name = "protobuf"
version = "5.29.5"
version = "5.29.4"
description = ""
optional = false
python-versions = ">=3.8"
groups = ["main"]
files = [
{file = "protobuf-5.29.5-cp310-abi3-win32.whl", hash = "sha256:3f1c6468a2cfd102ff4703976138844f78ebd1fb45f49011afc5139e9e283079"},
{file = "protobuf-5.29.5-cp310-abi3-win_amd64.whl", hash = "sha256:3f76e3a3675b4a4d867b52e4a5f5b78a2ef9565549d4037e06cf7b0942b1d3fc"},
{file = "protobuf-5.29.5-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:e38c5add5a311f2a6eb0340716ef9b039c1dfa428b28f25a7838ac329204a671"},
{file = "protobuf-5.29.5-cp38-abi3-manylinux2014_aarch64.whl", hash = "sha256:fa18533a299d7ab6c55a238bf8629311439995f2e7eca5caaff08663606e9015"},
{file = "protobuf-5.29.5-cp38-abi3-manylinux2014_x86_64.whl", hash = "sha256:63848923da3325e1bf7e9003d680ce6e14b07e55d0473253a690c3a8b8fd6e61"},
{file = "protobuf-5.29.5-cp38-cp38-win32.whl", hash = "sha256:ef91363ad4faba7b25d844ef1ada59ff1604184c0bcd8b39b8a6bef15e1af238"},
{file = "protobuf-5.29.5-cp38-cp38-win_amd64.whl", hash = "sha256:7318608d56b6402d2ea7704ff1e1e4597bee46d760e7e4dd42a3d45e24b87f2e"},
{file = "protobuf-5.29.5-cp39-cp39-win32.whl", hash = "sha256:6f642dc9a61782fa72b90878af134c5afe1917c89a568cd3476d758d3c3a0736"},
{file = "protobuf-5.29.5-cp39-cp39-win_amd64.whl", hash = "sha256:470f3af547ef17847a28e1f47200a1cbf0ba3ff57b7de50d22776607cd2ea353"},
{file = "protobuf-5.29.5-py3-none-any.whl", hash = "sha256:6cf42630262c59b2d8de33954443d94b746c952b01434fc58a417fdbd2e84bd5"},
{file = "protobuf-5.29.5.tar.gz", hash = "sha256:bc1463bafd4b0929216c35f437a8e28731a2b7fe3d98bb77a600efced5a15c84"},
{file = "protobuf-5.29.4-cp310-abi3-win32.whl", hash = "sha256:13eb236f8eb9ec34e63fc8b1d6efd2777d062fa6aaa68268fb67cf77f6839ad7"},
{file = "protobuf-5.29.4-cp310-abi3-win_amd64.whl", hash = "sha256:bcefcdf3976233f8a502d265eb65ea740c989bacc6c30a58290ed0e519eb4b8d"},
{file = "protobuf-5.29.4-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:307ecba1d852ec237e9ba668e087326a67564ef83e45a0189a772ede9e854dd0"},
{file = "protobuf-5.29.4-cp38-abi3-manylinux2014_aarch64.whl", hash = "sha256:aec4962f9ea93c431d5714ed1be1c93f13e1a8618e70035ba2b0564d9e633f2e"},
{file = "protobuf-5.29.4-cp38-abi3-manylinux2014_x86_64.whl", hash = "sha256:d7d3f7d1d5a66ed4942d4fefb12ac4b14a29028b209d4bfb25c68ae172059922"},
{file = "protobuf-5.29.4-cp38-cp38-win32.whl", hash = "sha256:1832f0515b62d12d8e6ffc078d7e9eb06969aa6dc13c13e1036e39d73bebc2de"},
{file = "protobuf-5.29.4-cp38-cp38-win_amd64.whl", hash = "sha256:476cb7b14914c780605a8cf62e38c2a85f8caff2e28a6a0bad827ec7d6c85d68"},
{file = "protobuf-5.29.4-cp39-cp39-win32.whl", hash = "sha256:fd32223020cb25a2cc100366f1dedc904e2d71d9322403224cdde5fdced0dabe"},
{file = "protobuf-5.29.4-cp39-cp39-win_amd64.whl", hash = "sha256:678974e1e3a9b975b8bc2447fca458db5f93a2fb6b0c8db46b6675b5b5346812"},
{file = "protobuf-5.29.4-py3-none-any.whl", hash = "sha256:3fde11b505e1597f71b875ef2fc52062b6a9740e5f7c8997ce878b6009145862"},
{file = "protobuf-5.29.4.tar.gz", hash = "sha256:4f1dfcd7997b31ef8f53ec82781ff434a28bf71d9102ddde14d076adcfc78c99"},
]
[[package]]
@@ -756,7 +820,7 @@ typing-extensions = ">=4.12.2"
[package.extras]
email = ["email-validator (>=2.0.0)"]
timezone = ["tzdata ; python_version >= \"3.9\" and platform_system == \"Windows\""]
timezone = ["tzdata"]
[[package]]
name = "pydantic-core"
@@ -922,6 +986,69 @@ files = [
[package.extras]
cli = ["click (>=5.0)"]
[[package]]
name = "pyyaml"
version = "6.0.2"
description = "YAML parser and emitter for Python"
optional = false
python-versions = ">=3.8"
groups = ["main"]
files = [
{file = "PyYAML-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0a9a2848a5b7feac301353437eb7d5957887edbf81d56e903999a75a3d743086"},
{file = "PyYAML-6.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:29717114e51c84ddfba879543fb232a6ed60086602313ca38cce623c1d62cfbf"},
{file = "PyYAML-6.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8824b5a04a04a047e72eea5cec3bc266db09e35de6bdfe34c9436ac5ee27d237"},
{file = "PyYAML-6.0.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7c36280e6fb8385e520936c3cb3b8042851904eba0e58d277dca80a5cfed590b"},
{file = "PyYAML-6.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ec031d5d2feb36d1d1a24380e4db6d43695f3748343d99434e6f5f9156aaa2ed"},
{file = "PyYAML-6.0.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:936d68689298c36b53b29f23c6dbb74de12b4ac12ca6cfe0e047bedceea56180"},
{file = "PyYAML-6.0.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:23502f431948090f597378482b4812b0caae32c22213aecf3b55325e049a6c68"},
{file = "PyYAML-6.0.2-cp310-cp310-win32.whl", hash = "sha256:2e99c6826ffa974fe6e27cdb5ed0021786b03fc98e5ee3c5bfe1fd5015f42b99"},
{file = "PyYAML-6.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:a4d3091415f010369ae4ed1fc6b79def9416358877534caf6a0fdd2146c87a3e"},
{file = "PyYAML-6.0.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cc1c1159b3d456576af7a3e4d1ba7e6924cb39de8f67111c735f6fc832082774"},
{file = "PyYAML-6.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1e2120ef853f59c7419231f3bf4e7021f1b936f6ebd222406c3b60212205d2ee"},
{file = "PyYAML-6.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5d225db5a45f21e78dd9358e58a98702a0302f2659a3c6cd320564b75b86f47c"},
{file = "PyYAML-6.0.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5ac9328ec4831237bec75defaf839f7d4564be1e6b25ac710bd1a96321cc8317"},
{file = "PyYAML-6.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3ad2a3decf9aaba3d29c8f537ac4b243e36bef957511b4766cb0057d32b0be85"},
{file = "PyYAML-6.0.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:ff3824dc5261f50c9b0dfb3be22b4567a6f938ccce4587b38952d85fd9e9afe4"},
{file = "PyYAML-6.0.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:797b4f722ffa07cc8d62053e4cff1486fa6dc094105d13fea7b1de7d8bf71c9e"},
{file = "PyYAML-6.0.2-cp311-cp311-win32.whl", hash = "sha256:11d8f3dd2b9c1207dcaf2ee0bbbfd5991f571186ec9cc78427ba5bd32afae4b5"},
{file = "PyYAML-6.0.2-cp311-cp311-win_amd64.whl", hash = "sha256:e10ce637b18caea04431ce14fabcf5c64a1c61ec9c56b071a4b7ca131ca52d44"},
{file = "PyYAML-6.0.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:c70c95198c015b85feafc136515252a261a84561b7b1d51e3384e0655ddf25ab"},
{file = "PyYAML-6.0.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ce826d6ef20b1bc864f0a68340c8b3287705cae2f8b4b1d932177dcc76721725"},
{file = "PyYAML-6.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1f71ea527786de97d1a0cc0eacd1defc0985dcf6b3f17bb77dcfc8c34bec4dc5"},
{file = "PyYAML-6.0.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9b22676e8097e9e22e36d6b7bda33190d0d400f345f23d4065d48f4ca7ae0425"},
{file = "PyYAML-6.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:80bab7bfc629882493af4aa31a4cfa43a4c57c83813253626916b8c7ada83476"},
{file = "PyYAML-6.0.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:0833f8694549e586547b576dcfaba4a6b55b9e96098b36cdc7ebefe667dfed48"},
{file = "PyYAML-6.0.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8b9c7197f7cb2738065c481a0461e50ad02f18c78cd75775628afb4d7137fb3b"},
{file = "PyYAML-6.0.2-cp312-cp312-win32.whl", hash = "sha256:ef6107725bd54b262d6dedcc2af448a266975032bc85ef0172c5f059da6325b4"},
{file = "PyYAML-6.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:7e7401d0de89a9a855c839bc697c079a4af81cf878373abd7dc625847d25cbd8"},
{file = "PyYAML-6.0.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:efdca5630322a10774e8e98e1af481aad470dd62c3170801852d752aa7a783ba"},
{file = "PyYAML-6.0.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:50187695423ffe49e2deacb8cd10510bc361faac997de9efef88badc3bb9e2d1"},
{file = "PyYAML-6.0.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0ffe8360bab4910ef1b9e87fb812d8bc0a308b0d0eef8c8f44e0254ab3b07133"},
{file = "PyYAML-6.0.2-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:17e311b6c678207928d649faa7cb0d7b4c26a0ba73d41e99c4fff6b6c3276484"},
{file = "PyYAML-6.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:70b189594dbe54f75ab3a1acec5f1e3faa7e8cf2f1e08d9b561cb41b845f69d5"},
{file = "PyYAML-6.0.2-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:41e4e3953a79407c794916fa277a82531dd93aad34e29c2a514c2c0c5fe971cc"},
{file = "PyYAML-6.0.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:68ccc6023a3400877818152ad9a1033e3db8625d899c72eacb5a668902e4d652"},
{file = "PyYAML-6.0.2-cp313-cp313-win32.whl", hash = "sha256:bc2fa7c6b47d6bc618dd7fb02ef6fdedb1090ec036abab80d4681424b84c1183"},
{file = "PyYAML-6.0.2-cp313-cp313-win_amd64.whl", hash = "sha256:8388ee1976c416731879ac16da0aff3f63b286ffdd57cdeb95f3f2e085687563"},
{file = "PyYAML-6.0.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:24471b829b3bf607e04e88d79542a9d48bb037c2267d7927a874e6c205ca7e9a"},
{file = "PyYAML-6.0.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d7fded462629cfa4b685c5416b949ebad6cec74af5e2d42905d41e257e0869f5"},
{file = "PyYAML-6.0.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d84a1718ee396f54f3a086ea0a66d8e552b2ab2017ef8b420e92edbc841c352d"},
{file = "PyYAML-6.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9056c1ecd25795207ad294bcf39f2db3d845767be0ea6e6a34d856f006006083"},
{file = "PyYAML-6.0.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:82d09873e40955485746739bcb8b4586983670466c23382c19cffecbf1fd8706"},
{file = "PyYAML-6.0.2-cp38-cp38-win32.whl", hash = "sha256:43fa96a3ca0d6b1812e01ced1044a003533c47f6ee8aca31724f78e93ccc089a"},
{file = "PyYAML-6.0.2-cp38-cp38-win_amd64.whl", hash = "sha256:01179a4a8559ab5de078078f37e5c1a30d76bb88519906844fd7bdea1b7729ff"},
{file = "PyYAML-6.0.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:688ba32a1cffef67fd2e9398a2efebaea461578b0923624778664cc1c914db5d"},
{file = "PyYAML-6.0.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a8786accb172bd8afb8be14490a16625cbc387036876ab6ba70912730faf8e1f"},
{file = "PyYAML-6.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d8e03406cac8513435335dbab54c0d385e4a49e4945d2909a581c83647ca0290"},
{file = "PyYAML-6.0.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f753120cb8181e736c57ef7636e83f31b9c0d1722c516f7e86cf15b7aa57ff12"},
{file = "PyYAML-6.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3b1fdb9dc17f5a7677423d508ab4f243a726dea51fa5e70992e59a7411c89d19"},
{file = "PyYAML-6.0.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0b69e4ce7a131fe56b7e4d770c67429700908fc0752af059838b1cfb41960e4e"},
{file = "PyYAML-6.0.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:a9f8c2e67970f13b16084e04f134610fd1d374bf477b17ec1599185cf611d725"},
{file = "PyYAML-6.0.2-cp39-cp39-win32.whl", hash = "sha256:6395c297d42274772abc367baaa79683958044e5d3835486c16da75d2a694631"},
{file = "PyYAML-6.0.2-cp39-cp39-win_amd64.whl", hash = "sha256:39693e1f8320ae4f43943590b49779ffb98acb81f788220ea932a6b6c51004d8"},
{file = "pyyaml-6.0.2.tar.gz", hash = "sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e"},
]
[[package]]
name = "setuptools"
version = "78.0.2"
@@ -935,13 +1062,13 @@ files = [
]
[package.extras]
check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1) ; sys_platform != \"cygwin\"", "ruff (>=0.8.0) ; sys_platform != \"cygwin\""]
core = ["importlib_metadata (>=6) ; python_version < \"3.10\"", "jaraco.functools (>=4)", "jaraco.text (>=3.7)", "more_itertools", "more_itertools (>=8.8)", "packaging (>=24.2)", "platformdirs (>=4.2.2)", "tomli (>=2.0.1) ; python_version < \"3.11\"", "wheel (>=0.43.0)"]
check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)", "ruff (>=0.8.0)"]
core = ["importlib_metadata (>=6)", "jaraco.functools (>=4)", "jaraco.text (>=3.7)", "more_itertools", "more_itertools (>=8.8)", "packaging (>=24.2)", "platformdirs (>=4.2.2)", "tomli (>=2.0.1)", "wheel (>=0.43.0)"]
cover = ["pytest-cov"]
doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "pyproject-hooks (!=1.1)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier", "towncrier (<24.7)"]
enabler = ["pytest-enabler (>=2.2)"]
test = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "ini2toml[lite] (>=0.14)", "jaraco.develop (>=7.21) ; python_version >= \"3.9\" and sys_platform != \"cygwin\"", "jaraco.envs (>=2.2)", "jaraco.path (>=3.7.2)", "jaraco.test (>=5.5)", "packaging (>=24.2)", "pip (>=19.1)", "pyproject-hooks (!=1.1)", "pytest (>=6,!=8.1.*)", "pytest-home (>=0.5)", "pytest-perf ; sys_platform != \"cygwin\"", "pytest-subprocess", "pytest-timeout", "pytest-xdist (>=3)", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel (>=0.44.0)"]
type = ["importlib_metadata (>=7.0.2) ; python_version < \"3.10\"", "jaraco.develop (>=7.21) ; sys_platform != \"cygwin\"", "mypy (==1.14.*)", "pytest-mypy"]
test = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "ini2toml[lite] (>=0.14)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.7.2)", "jaraco.test (>=5.5)", "packaging (>=24.2)", "pip (>=19.1)", "pyproject-hooks (!=1.1)", "pytest (>=6,!=8.1.*)", "pytest-home (>=0.5)", "pytest-perf", "pytest-subprocess", "pytest-timeout", "pytest-xdist (>=3)", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel (>=0.44.0)"]
type = ["importlib_metadata (>=7.0.2)", "jaraco.develop (>=7.21)", "mypy (==1.14.*)", "pytest-mypy"]
[[package]]
name = "six"
@@ -971,6 +1098,30 @@ files = [
doc = ["reno", "sphinx"]
test = ["pytest", "tornado (>=4.5)", "typeguard"]
[[package]]
name = "types-python-dateutil"
version = "2.9.0.20241206"
description = "Typing stubs for python-dateutil"
optional = false
python-versions = ">=3.8"
groups = ["main"]
files = [
{file = "types_python_dateutil-2.9.0.20241206-py3-none-any.whl", hash = "sha256:e248a4bc70a486d3e3ec84d0dc30eec3a5f979d6e7ee4123ae043eedbb987f53"},
{file = "types_python_dateutil-2.9.0.20241206.tar.gz", hash = "sha256:18f493414c26ffba692a72369fea7a154c502646301ebfe3d56a04b3767284cb"},
]
[[package]]
name = "types-pyyaml"
version = "6.0.12.20241230"
description = "Typing stubs for PyYAML"
optional = false
python-versions = ">=3.8"
groups = ["main"]
files = [
{file = "types_PyYAML-6.0.12.20241230-py3-none-any.whl", hash = "sha256:fa4d32565219b68e6dee5f67534c722e53c00d1cfc09c435ef04d7353e1e96e6"},
{file = "types_pyyaml-6.0.12.20241230.tar.gz", hash = "sha256:7f07622dbd34bb9c8b264fe860a17e0efcad00d50b5f27e93984909d9363498c"},
]
[[package]]
name = "typing-extensions"
version = "4.12.2"
@@ -996,7 +1147,7 @@ files = [
]
[package.extras]
brotli = ["brotli (>=1.0.9) ; platform_python_implementation == \"CPython\"", "brotlicffi (>=0.8.0) ; platform_python_implementation != \"CPython\""]
brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"]
h2 = ["h2 (>=4,<5)"]
socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"]
zstd = ["zstandard (>=0.18.0)"]
@@ -1101,4 +1252,4 @@ propcache = ">=0.2.0"
[metadata]
lock-version = "2.1"
python-versions = "^3.10"
content-hash = "3cd0ce503113baf99097492923271a82ac4986176ce73805643b0dee91ce0113"
content-hash = "74c12e499aa797ca5c8559af579f1212b0e4e3a77f068f9385db39d70ba304e0"

View File

@@ -0,0 +1,3 @@
import main from './main';
export { main };

View File

@@ -0,0 +1,29 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"log"\n\t"time"\n\n\t"github.com/google/uuid"\n\t"github.com/oapi-codegen/runtime/types"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/rest"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n)\n\nfunc main() {\n\t// > Setup\n\n\thatchet, err := v1.NewHatchetClient()\n\tif err != nil {\n\t\tlog.Fatalf("failed to create hatchet client: %v", err)\n\t}\n\n\tctx := context.Background()\n\n\tworkflows, err := hatchet.Workflows().List(ctx, nil)\n\tif err != nil {\n\t\tlog.Fatalf("failed to list workflows: %v", err)\n\t}\n\n\tif workflows == nil || workflows.Rows == nil || len(*workflows.Rows) == 0 {\n\t\tlog.Fatalf("no workflows found")\n\t}\n\n\tselectedWorkflow := (*workflows.Rows)[0]\n\tselectedWorkflowUUID := uuid.MustParse(selectedWorkflow.Metadata.Id)\n\n\n\t// > List runs\n\tworkflowRuns, err := hatchet.Runs().List(ctx, rest.V1WorkflowRunListParams{\n\t\tWorkflowIds: &[]types.UUID{selectedWorkflowUUID},\n\t})\n\tif err != nil || workflowRuns == nil || workflowRuns.JSON200 == nil || workflowRuns.JSON200.Rows == nil {\n\t\tlog.Fatalf("failed to list workflow runs for workflow %s: %v", selectedWorkflow.Name, err)\n\t}\n\n\tvar runIds []types.UUID\n\n\tfor _, run := range workflowRuns.JSON200.Rows {\n\t\trunIds = append(runIds, uuid.MustParse(run.Metadata.Id))\n\t}\n\n\n\t// > Cancel by run ids\n\t_, err = hatchet.Runs().Cancel(ctx, rest.V1CancelTaskRequest{\n\t\tExternalIds: &runIds,\n\t})\n\tif err != nil {\n\t\tlog.Fatalf("failed to cancel runs by ids: %v", err)\n\t}\n\n\n\t// > Cancel by filters\n\ttNow := time.Now().UTC()\n\n\t_, err = hatchet.Runs().Cancel(ctx, rest.V1CancelTaskRequest{\n\t\tFilter: &rest.V1TaskFilter{\n\t\t\tSince: tNow.Add(-24 * time.Hour),\n\t\t\tUntil: &tNow,\n\t\t\tStatuses: &[]rest.V1TaskStatus{rest.V1TaskStatusRUNNING},\n\t\t\tWorkflowIds: &[]types.UUID{selectedWorkflowUUID},\n\t\t\tAdditionalMetadata: &[]string{`{"key": "value"}`},\n\t\t},\n\t})\n\tif err != nil {\n\t\tlog.Fatalf("failed to cancel runs by filters: %v", err)\n\t}\n\n\n\tfmt.Println("cancelled all runs for workflow", selectedWorkflow.Name)\n}\n',
source: 'out/go/bulk-operations/main.go',
blocks: {
setup: {
start: 18,
stop: 37,
},
list_runs: {
start: 40,
stop: 52,
},
cancel_by_run_ids: {
start: 55,
stop: 61,
},
cancel_by_filters: {
start: 64,
stop: 78,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,17 @@
import * as bulk_operations from './bulk-operations';
import * as migration_guides from './migration-guides';
import * as quickstart from './quickstart';
import * as run from './run';
import * as streaming from './streaming';
import * as worker from './worker';
import * as workflows from './workflows';
import * as z_v0 from './z_v0';
export { bulk_operations };
export { migration_guides };
export { quickstart };
export { run };
export { streaming };
export { worker };
export { workflows };
export { z_v0 };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package migration_guides\n\nimport (\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n)\n\nfunc HatchetClient() (v1.HatchetClient, error) {\n\thatchet, err := v1.NewHatchetClient()\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn hatchet, nil\n}\n',
source: 'out/go/migration-guides/hatchet-client.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,5 @@
import hatchet_client from './hatchet-client';
import mergent from './mergent';
export { hatchet_client };
export { mergent };

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
import * as run from './run';
import * as worker from './worker';
export { run };
export { worker };

View File

@@ -0,0 +1,3 @@
import main from './main';
export { main };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\thatchet_client "github.com/hatchet-dev/hatchet/pkg/examples/quickstart/hatchet_client"\n\tworkflows "github.com/hatchet-dev/hatchet/pkg/examples/quickstart/workflows"\n)\n\nfunc main() {\n\thatchet, err := hatchet_client.HatchetClient()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tsimple := workflows.FirstTask(hatchet)\n\n\tresult, err := simple.Run(context.Background(), workflows.SimpleInput{\n\t\tMessage: "Hello, World!",\n\t})\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(\n\t\t"Finished running task, and got the transformed message! The transformed message is:",\n\t\tresult.ToLower.TransformedMessage,\n\t)\n}\n',
source: 'out/go/quickstart/cmd/run/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import main from './main';
export { main };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\thatchet_client "github.com/hatchet-dev/hatchet/pkg/examples/quickstart/hatchet_client"\n\tworkflows "github.com/hatchet-dev/hatchet/pkg/examples/quickstart/workflows"\n\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/worker"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n)\n\nfunc main() {\n\n\thatchet, err := hatchet_client.HatchetClient()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tworker, err := hatchet.Worker(\n\t\tworker.WorkerOpts{\n\t\t\tName: "first-worker",\n\t\t\tWorkflows: []workflow.WorkflowBase{\n\t\t\t\tworkflows.FirstTask(hatchet),\n\t\t\t},\n\t\t},\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// we construct an interrupt context to handle Ctrl+C\n\t// you can pass in your own context.Context here to the worker\n\tinterruptCtx, cancel := cmdutils.NewInterruptContext()\n\n\tdefer cancel()\n\n\terr = worker.StartBlocking(interruptCtx)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n',
source: 'out/go/quickstart/cmd/worker/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package hatchet_client\n\nimport (\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/joho/godotenv"\n)\n\nfunc HatchetClient() (v1.HatchetClient, error) {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn v1.NewHatchetClient()\n}\n',
source: 'out/go/quickstart/hatchet_client/hatchet_client.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import hatchet_client from './hatchet_client';
export { hatchet_client };

View File

@@ -0,0 +1,7 @@
import * as cmd from './cmd';
import * as hatchet_client from './hatchet_client';
import * as workflows from './workflows';
export { cmd };
export { hatchet_client };
export { workflows };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package workflows\n\nimport (\n\t"fmt"\n\t"strings"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype SimpleInput struct {\n\tMessage string `json:"message"`\n}\n\ntype LowerOutput struct {\n\tTransformedMessage string `json:"transformed_message"`\n}\n\ntype SimpleResult struct {\n\tToLower LowerOutput\n}\n\nfunc FirstTask(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[SimpleInput, SimpleResult] {\n\tsimple := factory.NewWorkflow[SimpleInput, SimpleResult](\n\t\tcreate.WorkflowCreateOpts[SimpleInput]{\n\t\t\tName: "first-task",\n\t\t},\n\t\thatchet,\n\t)\n\n\tsimple.Task(\n\t\tcreate.WorkflowTask[SimpleInput, SimpleResult]{\n\t\t\tName: "first-task",\n\t\t},\n\t\tfunc(ctx worker.HatchetContext, input SimpleInput) (any, error) {\n\t\t\tfmt.Println("first-task task called")\n\t\t\treturn &LowerOutput{\n\t\t\t\tTransformedMessage: strings.ToLower(input.Message),\n\t\t\t}, nil\n\t\t},\n\t)\n\n\treturn simple\n}\n',
source: 'out/go/quickstart/workflows/first_task.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import first_task from './first_task';
export { first_task };

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,17 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\tv1_workflows "github.com/hatchet-dev/hatchet/examples/go/workflows"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/joho/godotenv"\n)\n\nfunc bulk() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\thatchet, err := v1.NewHatchetClient()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tctx := context.Background()\n\t// > Bulk Run Tasks\n\tsimple := v1_workflows.Simple(hatchet)\n\tbulkRunIds, err := simple.RunBulkNoWait(ctx, []v1_workflows.SimpleInput{\n\t\t{\n\t\t\tMessage: "Hello, World!",\n\t\t},\n\t\t{\n\t\t\tMessage: "Hello, Moon!",\n\t\t},\n\t})\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(bulkRunIds)\n}\n',
source: 'out/go/run/bulk.go',
blocks: {
bulk_run_tasks: {
start: 26,
stop: 40,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,25 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\tv1_workflows "github.com/hatchet-dev/hatchet/examples/go/workflows"\n\t"github.com/hatchet-dev/hatchet/pkg/client/rest"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/joho/godotenv"\n)\n\nfunc cron() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\thatchet, err := v1.NewHatchetClient()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t// > Create\n\tsimple := v1_workflows.Simple(hatchet)\n\n\tctx := context.Background()\n\n\tresult, err := simple.Cron(\n\t\tctx,\n\t\t"daily-run",\n\t\t"0 0 * * *",\n\t\tv1_workflows.SimpleInput{\n\t\t\tMessage: "Hello, World!",\n\t\t},\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// it may be useful to save the cron id for later\n\tfmt.Println(result.Metadata.Id)\n\n\t// > Delete\n\thatchet.Crons().Delete(ctx, result.Metadata.Id)\n\n\t// > List\n\tcrons, err := hatchet.Crons().List(ctx, rest.CronWorkflowListParams{\n\t\tAdditionalMetadata: &[]string{"user:daily-run"},\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(crons)\n}\n',
source: 'out/go/run/cron.go',
blocks: {
create: {
start: 25,
stop: 43,
},
delete: {
start: 46,
stop: 46,
},
list: {
start: 49,
stop: 51,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,29 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\n\t"github.com/google/uuid"\n\t"github.com/joho/godotenv"\n\n\tv1_workflows "github.com/hatchet-dev/hatchet/examples/go/workflows"\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/client/rest"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n)\n\nfunc event() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\thatchet, err := v1.NewHatchetClient()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t// > Pushing an Event\n\terr = hatchet.Events().Push(\n\t\tcontext.Background(),\n\t\t"simple-event:create",\n\t\tv1_workflows.SimpleInput{\n\t\t\tMessage: "Hello, World!",\n\t\t},\n\t)\n\n\t// > Create a filter\n\tpayload := map[string]interface{}{\n\t\t"main_character": "Anna",\n\t\t"supporting_character": "Stiva",\n\t\t"location": "Moscow",\n\t}\n\n\t_, err = hatchet.Filters().Create(\n\t\tcontext.Background(),\n\t\trest.V1CreateFilterRequest{\n\t\t\tWorkflowId: uuid.New(),\n\t\t\tExpression: "input.shouldSkip == false",\n\t\t\tScope: "foobarbaz",\n\t\t\tPayload: &payload,\n\t\t},\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// > Skip a run\n\tskipPayload := map[string]interface{}{\n\t\t"shouldSkip": true,\n\t}\n\tskipScope := "foobarbaz"\n\terr = hatchet.Events().Push(\n\t\tcontext.Background(),\n\t\t"simple-event:create",\n\t\tskipPayload,\n\t\tclient.WithFilterScope(&skipScope),\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// > Trigger a run\n\ttriggerPayload := map[string]interface{}{\n\t\t"shouldSkip": false,\n\t}\n\ttriggerScope := "foobarbaz"\n\terr = hatchet.Events().Push(\n\t\tcontext.Background(),\n\t\t"simple-event:create",\n\t\ttriggerPayload,\n\t\tclient.WithFilterScope(&triggerScope),\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n',
source: 'out/go/run/event.go',
blocks: {
pushing_an_event: {
start: 27,
stop: 33,
},
create_a_filter: {
start: 36,
stop: 50,
},
skip_a_run: {
start: 57,
stop: 66,
},
trigger_a_run: {
start: 73,
stop: 82,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,13 @@
import all from './all';
import bulk from './bulk';
import cron from './cron';
import event from './event';
import priority from './priority';
import simple from './simple';
export { all };
export { bulk };
export { cron };
export { event };
export { priority };
export { simple };

View File

@@ -0,0 +1,21 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\tv1_workflows "github.com/hatchet-dev/hatchet/examples/go/workflows"\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/joho/godotenv"\n)\n\nfunc priority() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\thatchet, err := v1.NewHatchetClient()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tctx := context.Background()\n\n\tpriorityWorkflow := v1_workflows.Priority(hatchet)\n\n\t// > Running a Task with Priority\n\tpriority := int32(3)\n\n\trunId, err := priorityWorkflow.RunNoWait(ctx, v1_workflows.PriorityInput{\n\t\tUserId: "1234",\n\t}, client.WithPriority(priority))\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(runId)\n\n\t// > Schedule and cron\n\tschedulePriority := int32(3)\n\trunAt := time.Now().Add(time.Minute)\n\n\tscheduledRunId, _ := priorityWorkflow.Schedule(ctx, runAt, v1_workflows.PriorityInput{\n\t\tUserId: "1234",\n\t}, client.WithPriority(schedulePriority))\n\n\tcronId, _ := priorityWorkflow.Cron(ctx, "my-cron", "* * * * *", v1_workflows.PriorityInput{\n\t\tUserId: "1234",\n\t}, client.WithPriority(schedulePriority))\n\n\tfmt.Println(scheduledRunId)\n\tfmt.Println(cronId)\n\n}\n',
source: 'out/go/run/priority.go',
blocks: {
running_a_task_with_priority: {
start: 31,
stop: 35,
},
schedule_and_cron: {
start: 44,
stop: 53,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,29 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"sync"\n\n\tv1_workflows "github.com/hatchet-dev/hatchet/examples/go/workflows"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/joho/godotenv"\n)\n\nfunc simple() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\thatchet, err := v1.NewHatchetClient()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tctx := context.Background()\n\t// > Running a Task\n\tsimple := v1_workflows.Simple(hatchet)\n\tresult, err := simple.Run(ctx, v1_workflows.SimpleInput{\n\t\tMessage: "Hello, World!",\n\t})\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(result.TransformedMessage)\n\n\t// > Running Multiple Tasks\n\tvar results []string\n\tvar resultsMutex sync.Mutex\n\tvar errs []error\n\tvar errsMutex sync.Mutex\n\n\twg := sync.WaitGroup{}\n\twg.Add(2)\n\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tresult, err := simple.Run(ctx, v1_workflows.SimpleInput{\n\t\t\tMessage: "Hello, World!",\n\t\t})\n\n\t\tif err != nil {\n\t\t\terrsMutex.Lock()\n\t\t\terrs = append(errs, err)\n\t\t\terrsMutex.Unlock()\n\t\t\treturn\n\t\t}\n\n\t\tresultsMutex.Lock()\n\t\tresults = append(results, result.TransformedMessage)\n\t\tresultsMutex.Unlock()\n\t}()\n\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tresult, err := simple.Run(ctx, v1_workflows.SimpleInput{\n\t\t\tMessage: "Hello, Moon!",\n\t\t})\n\n\t\tif err != nil {\n\t\t\terrsMutex.Lock()\n\t\t\terrs = append(errs, err)\n\t\t\terrsMutex.Unlock()\n\t\t\treturn\n\t\t}\n\n\t\tresultsMutex.Lock()\n\t\tresults = append(results, result.TransformedMessage)\n\t\tresultsMutex.Unlock()\n\t}()\n\n\twg.Wait()\n\n\t// > Running a Task Without Waiting\n\tsimple = v1_workflows.Simple(hatchet)\n\trunRef, err := simple.RunNoWait(ctx, v1_workflows.SimpleInput{\n\t\tMessage: "Hello, World!",\n\t})\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// The Run Ref Exposes an ID that can be used to wait for the task to complete\n\t// or check on the status of the task\n\trunId := runRef.RunId()\n\tfmt.Println(runId)\n\n\t// > Subscribing to results\n\t// finally, we can wait for the task to complete and get the result\n\tfinalResult, err := runRef.Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(finalResult)\n}\n',
source: 'out/go/run/simple.go',
blocks: {
running_a_task: {
start: 27,
stop: 36,
},
running_multiple_tasks: {
start: 39,
stop: 83,
},
running_a_task_without_waiting: {
start: 86,
stop: 98,
},
subscribing_to_results: {
start: 101,
stop: 108,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import main from './main';
export { main };

View File

@@ -0,0 +1,17 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"log"\n\n\t"github.com/hatchet-dev/hatchet/examples/go/streaming/shared"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n)\n\n// > Consume\nfunc main() {\n\thatchet, err := v1.NewHatchetClient()\n\tif err != nil {\n\t\tlog.Fatalf("Failed to create Hatchet client: %v", err)\n\t}\n\n\tctx := context.Background()\n\n\tstreamingWorkflow := shared.StreamingWorkflow(hatchet)\n\n\tworkflowRun, err := streamingWorkflow.RunNoWait(ctx, shared.StreamTaskInput{})\n\tif err != nil {\n\t\tlog.Fatalf("Failed to run workflow: %v", err)\n\t}\n\n\tid := workflowRun.RunId()\n\tstream, err := hatchet.Runs().SubscribeToStream(ctx, id)\n\tif err != nil {\n\t\tlog.Fatalf("Failed to subscribe to stream: %v", err)\n\t}\n\n\tfor content := range stream {\n\t\tfmt.Print(content)\n\t}\n\n\tfmt.Println("\\nStreaming completed!")\n}\n\n',
source: 'out/go/streaming/consumer/main.go',
blocks: {
consume: {
start: 13,
stop: 40,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,9 @@
import * as consumer from './consumer';
import * as server from './server';
import * as shared from './shared';
import * as worker from './worker';
export { consumer };
export { server };
export { shared };
export { worker };

View File

@@ -0,0 +1,3 @@
import main from './main';
export { main };

View File

@@ -0,0 +1,17 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"log"\n\t"net/http"\n\t"time"\n\n\t"github.com/hatchet-dev/hatchet/examples/go/streaming/shared"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n)\n\n// > Server\nfunc main() {\n\thatchet, err := v1.NewHatchetClient()\n\tif err != nil {\n\t\tlog.Fatalf("Failed to create Hatchet client: %v", err)\n\t}\n\n\tstreamingWorkflow := shared.StreamingWorkflow(hatchet)\n\n\thttp.HandleFunc("/stream", func(w http.ResponseWriter, r *http.Request) {\n\t\tctx := context.Background()\n\n\t\tw.Header().Set("Content-Type", "text/plain")\n\t\tw.Header().Set("Cache-Control", "no-cache")\n\t\tw.Header().Set("Connection", "keep-alive")\n\n\t\tworkflowRun, err := streamingWorkflow.RunNoWait(ctx, shared.StreamTaskInput{})\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tstream, err := hatchet.Runs().SubscribeToStream(ctx, workflowRun.RunId())\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tflusher, _ := w.(http.Flusher)\n\t\tfor content := range stream {\n\t\t\tfmt.Fprint(w, content)\n\t\t\tif flusher != nil {\n\t\t\t\tflusher.Flush()\n\t\t\t}\n\t\t}\n\t})\n\n\tserver := &http.Server{\n\t\tAddr: ":8000",\n\t\tReadTimeout: 5 * time.Second,\n\t\tWriteTimeout: 10 * time.Second,\n\t}\n\n\tif err := server.ListenAndServe(); err != nil {\n\t\tlog.Println("Failed to start server:", err)\n\t}\n}\n\n',
source: 'out/go/streaming/server/main.go',
blocks: {
server: {
start: 15,
stop: 61,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import task from './task';
export { task };

View File

@@ -0,0 +1,17 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package shared\n\nimport (\n\t"time"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype StreamTaskInput struct{}\n\ntype StreamTaskOutput struct {\n\tMessage string `json:"message"`\n}\n\n// > Streaming\nconst annaKarenina = `\nHappy families are all alike; every unhappy family is unhappy in its own way.\n\nEverything was in confusion in the Oblonskys\' house. The wife had discovered that the husband was carrying on an intrigue with a French girl, who had been a governess in their family, and she had announced to her husband that she could not go on living in the same house with him.\n`\n\nfunc createChunks(content string, n int) []string {\n\tvar chunks []string\n\tfor i := 0; i < len(content); i += n {\n\t\tend := i + n\n\t\tif end > len(content) {\n\t\t\tend = len(content)\n\t\t}\n\t\tchunks = append(chunks, content[i:end])\n\t}\n\treturn chunks\n}\n\nfunc StreamTask(ctx worker.HatchetContext, input StreamTaskInput) (*StreamTaskOutput, error) {\n\ttime.Sleep(2 * time.Second)\n\n\tchunks := createChunks(annaKarenina, 10)\n\n\tfor _, chunk := range chunks {\n\t\tctx.PutStream(chunk)\n\t\ttime.Sleep(200 * time.Millisecond)\n\t}\n\n\treturn &StreamTaskOutput{\n\t\tMessage: "Streaming completed",\n\t}, nil\n}\n\n\nfunc StreamingWorkflow(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[StreamTaskInput, StreamTaskOutput] {\n\treturn factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "stream-example",\n\t\t},\n\t\tStreamTask,\n\t\thatchet,\n\t)\n}\n',
source: 'out/go/streaming/shared/task.go',
blocks: {
streaming: {
start: 20,
stop: 52,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import main from './main';
export { main };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"log"\n\n\t"github.com/hatchet-dev/hatchet/examples/go/streaming/shared"\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\tv1worker "github.com/hatchet-dev/hatchet/pkg/v1/worker"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n)\n\nfunc main() {\n\thatchet, err := v1.NewHatchetClient()\n\tif err != nil {\n\t\tlog.Fatalf("Failed to create Hatchet client: %v", err)\n\t}\n\n\tstreamingWorkflow := shared.StreamingWorkflow(hatchet)\n\n\tw, err := hatchet.Worker(v1worker.WorkerOpts{\n\t\tName: "streaming-worker",\n\t\tWorkflows: []workflow.WorkflowBase{\n\t\t\tstreamingWorkflow,\n\t\t},\n\t})\n\tif err != nil {\n\t\tlog.Fatalf("Failed to create worker: %v", err)\n\t}\n\n\tinterruptCtx, cancel := cmdutils.NewInterruptContext()\n\tdefer cancel()\n\n\tlog.Println("Starting streaming worker...")\n\n\tif err := w.StartBlocking(interruptCtx); err != nil {\n\t\tlog.Println("Worker failed:", err)\n\t}\n}\n',
source: 'out/go/streaming/worker/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import start from './start';
export { start };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"fmt"\n\t"os"\n\t"time"\n\n\tv1_workflows "github.com/hatchet-dev/hatchet/examples/go/workflows"\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/worker"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/joho/godotenv"\n)\n\nfunc main() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\thatchet, err := v1.NewHatchetClient()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Get workflow name from command line arguments\n\tvar workflowName string\n\tif len(os.Args) > 1 {\n\t\tworkflowName = os.Args[1]\n\t\tfmt.Println("workflow name provided:", workflowName)\n\t}\n\n\t// Define workflows map\n\tworkflowMap := map[string][]workflow.WorkflowBase{\n\t\t"dag": {v1_workflows.DagWorkflow(hatchet)},\n\t\t"on-failure": {v1_workflows.OnFailure(hatchet)},\n\t\t"simple": {v1_workflows.Simple(hatchet)},\n\t\t"sleep": {v1_workflows.DurableSleep(hatchet)},\n\t\t"child": {v1_workflows.Parent(hatchet), v1_workflows.Child(hatchet)},\n\t\t"cancellation": {v1_workflows.Cancellation(hatchet)},\n\t\t"timeout": {v1_workflows.Timeout(hatchet)},\n\t\t"sticky": {v1_workflows.Sticky(hatchet), v1_workflows.StickyDag(hatchet), v1_workflows.Child(hatchet)},\n\t\t"retries": {v1_workflows.Retries(hatchet), v1_workflows.RetriesWithCount(hatchet), v1_workflows.WithBackoff(hatchet)},\n\t\t"on-cron": {v1_workflows.OnCron(hatchet)},\n\t\t"non-retryable": {v1_workflows.NonRetryableError(hatchet)},\n\t\t"priority": {v1_workflows.Priority(hatchet)},\n\t}\n\n\t// Add an "all" option that registers all workflows\n\tallWorkflows := []workflow.WorkflowBase{}\n\tfor _, wfs := range workflowMap {\n\t\tallWorkflows = append(allWorkflows, wfs...)\n\t}\n\tworkflowMap["all"] = allWorkflows\n\n\t// Lookup workflow from map\n\tworkflow, ok := workflowMap[workflowName]\n\tif !ok {\n\t\tfmt.Println("Invalid workflow name provided. Usage: go run examples/v1/worker/start.go [workflow-name]")\n\t\tfmt.Println("Available workflows:", getAvailableWorkflows(workflowMap))\n\t\tos.Exit(1)\n\t}\n\n\tvar slots int\n\tif workflowName == "priority" {\n\t\tslots = 1\n\t} else {\n\t\tslots = 100\n\t}\n\n\tworker, err := hatchet.Worker(\n\t\tworker.WorkerOpts{\n\t\t\tName: fmt.Sprintf("%s-worker", workflowName),\n\t\t\tWorkflows: workflow,\n\t\t\tSlots: slots,\n\t\t},\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tinterruptCtx, cancel := cmdutils.NewInterruptContext()\n\n\terr = worker.StartBlocking(interruptCtx)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tgo func() {\n\t\ttime.Sleep(10 * time.Second)\n\t\tcancel()\n\t}()\n}\n\n// Helper function to get available workflows as a formatted string\nfunc getAvailableWorkflows(workflowMap map[string][]workflow.WorkflowBase) string {\n\tvar workflows string\n\tcount := 0\n\tfor name := range workflowMap {\n\t\tif count > 0 {\n\t\t\tworkflows += ", "\n\t\t}\n\t\tworkflows += fmt.Sprintf("\'%s\'", name)\n\t\tcount++\n\t}\n\treturn workflows\n}\n',
source: 'out/go/worker/start.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,17 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"errors"\n\t"time"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype CancellationInput struct{}\ntype CancellationResult struct {\n\tCompleted bool\n}\n\nfunc Cancellation(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[CancellationInput, CancellationResult] {\n\n\t// > Cancelled task\n\t// Create a task that sleeps for 10 seconds and checks if it was cancelled\n\tcancellation := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "cancellation-task",\n\t\t}, func(ctx worker.HatchetContext, input CancellationInput) (*CancellationResult, error) {\n\t\t\t// Sleep for 10 seconds\n\t\t\ttime.Sleep(10 * time.Second)\n\n\t\t\t// Check if the context was cancelled\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn nil, errors.New("Task was cancelled")\n\t\t\tdefault:\n\t\t\t\t// Continue execution\n\t\t\t}\n\n\t\t\treturn &CancellationResult{\n\t\t\t\tCompleted: true,\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn cancellation\n}\n',
source: 'out/go/workflows/cancellations.go',
blocks: {
cancelled_task: {
start: 22,
stop: 43,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype ChildInput struct {\n\tN int `json:"n"`\n}\n\ntype ValueOutput struct {\n\tValue int `json:"value"`\n}\n\ntype ParentInput struct {\n\tN int `json:"n"`\n}\n\ntype SumOutput struct {\n\tResult int `json:"result"`\n}\n\nfunc Child(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[ChildInput, ValueOutput] {\n\tchild := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "child",\n\t\t}, func(ctx worker.HatchetContext, input ChildInput) (*ValueOutput, error) {\n\t\t\treturn &ValueOutput{\n\t\t\t\tValue: input.N,\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn child\n}\n\nfunc Parent(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[ParentInput, SumOutput] {\n\n\tchild := Child(hatchet)\n\tparent := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "parent",\n\t\t}, func(ctx worker.HatchetContext, input ParentInput) (*SumOutput, error) {\n\n\t\t\tsum := 0\n\n\t\t\t// Launch child workflows in parallel\n\t\t\tresults := make([]*ValueOutput, 0, input.N)\n\t\t\tfor j := 0; j < input.N; j++ {\n\t\t\t\tresult, err := child.RunAsChild(ctx, ChildInput{N: j}, workflow.RunAsChildOpts{})\n\n\t\t\t\tif err != nil {\n\t\t\t\t\t// firstErr = err\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\n\t\t\t\tresults = append(results, result)\n\n\t\t\t}\n\n\t\t\t// Sum results from all children\n\t\t\tfor _, result := range results {\n\t\t\t\tsum += result.Value\n\t\t\t}\n\n\t\t\treturn &SumOutput{\n\t\t\t\tResult: sum,\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn parent\n}\n',
source: 'out/go/workflows/child-workflows.go',
blocks: {},
highlights: {},
};
export default snippet;

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,21 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"math/rand"\n\t"time"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\t"github.com/hatchet-dev/hatchet/pkg/client/types"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype ConcurrencyInput struct {\n\tMessage string\n\tTier string\n\tAccount string\n}\n\ntype TransformedOutput struct {\n\tTransformedMessage string\n}\n\nfunc ConcurrencyRoundRobin(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[ConcurrencyInput, TransformedOutput] {\n\t// > Concurrency Strategy With Key\n\tvar maxRuns int32 = 1\n\tstrategy := types.GroupRoundRobin\n\n\tconcurrency := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "simple-concurrency",\n\t\t\tConcurrency: []*types.Concurrency{\n\t\t\t\t{\n\t\t\t\t\tExpression: "input.GroupKey",\n\t\t\t\t\tMaxRuns: &maxRuns,\n\t\t\t\t\tLimitStrategy: &strategy,\n\t\t\t\t},\n\t\t\t},\n\t\t}, func(ctx worker.HatchetContext, input ConcurrencyInput) (*TransformedOutput, error) {\n\t\t\t// Random sleep between 200ms and 1000ms\n\t\t\ttime.Sleep(time.Duration(200+rand.Intn(800)) * time.Millisecond)\n\n\t\t\treturn &TransformedOutput{\n\t\t\t\tTransformedMessage: input.Message,\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn concurrency\n}\n\nfunc MultipleConcurrencyKeys(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[ConcurrencyInput, TransformedOutput] {\n\t// > Multiple Concurrency Keys\n\tstrategy := types.GroupRoundRobin\n\tvar maxRuns int32 = 20\n\n\tconcurrency := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "simple-concurrency",\n\t\t\tConcurrency: []*types.Concurrency{\n\t\t\t\t{\n\t\t\t\t\tExpression: "input.Tier",\n\t\t\t\t\tMaxRuns: &maxRuns,\n\t\t\t\t\tLimitStrategy: &strategy,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tExpression: "input.Account",\n\t\t\t\t\tMaxRuns: &maxRuns,\n\t\t\t\t\tLimitStrategy: &strategy,\n\t\t\t\t},\n\t\t\t},\n\t\t}, func(ctx worker.HatchetContext, input ConcurrencyInput) (*TransformedOutput, error) {\n\t\t\t// Random sleep between 200ms and 1000ms\n\t\t\ttime.Sleep(time.Duration(200+rand.Intn(800)) * time.Millisecond)\n\n\t\t\treturn &TransformedOutput{\n\t\t\t\tTransformedMessage: input.Message,\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn concurrency\n}\n',
source: 'out/go/workflows/concurrency-rr.go',
blocks: {
concurrency_strategy_with_key: {
start: 27,
stop: 49,
},
multiple_concurrency_keys: {
start: 56,
stop: 83,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"fmt"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype DagWithConditionsInput struct {\n\tMessage string\n}\n\ntype DagWithConditionsResult struct {\n\tStep1 SimpleOutput\n\tStep2 SimpleOutput\n}\n\ntype conditionOpts = create.WorkflowTask[DagWithConditionsInput, DagWithConditionsResult]\n\nfunc DagWithConditionsWorkflow(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[DagWithConditionsInput, DagWithConditionsResult] {\n\n\tsimple := factory.NewWorkflow[DagWithConditionsInput, DagWithConditionsResult](\n\t\tcreate.WorkflowCreateOpts[DagWithConditionsInput]{\n\t\t\tName: "simple-dag",\n\t\t},\n\t\thatchet,\n\t)\n\n\tstep1 := simple.Task(\n\t\tconditionOpts{\n\t\t\tName: "Step1",\n\t\t}, func(ctx worker.HatchetContext, input DagWithConditionsInput) (interface{}, error) {\n\t\t\treturn &SimpleOutput{\n\t\t\t\tStep: 1,\n\t\t\t}, nil\n\t\t},\n\t)\n\n\tsimple.Task(\n\t\tconditionOpts{\n\t\t\tName: "Step2",\n\t\t\tParents: []create.NamedTask{\n\t\t\t\tstep1,\n\t\t\t},\n\t\t}, func(ctx worker.HatchetContext, input DagWithConditionsInput) (interface{}, error) {\n\n\t\t\tvar step1Output SimpleOutput\n\t\t\terr := ctx.ParentOutput(step1, &step1Output)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tfmt.Println(step1Output.Step)\n\n\t\t\treturn &SimpleOutput{\n\t\t\t\tStep: 2,\n\t\t\t}, nil\n\t\t},\n\t)\n\n\treturn simple\n}\n',
source: 'out/go/workflows/dag-with-conditions.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,25 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype DagInput struct {\n\tMessage string\n}\n\ntype SimpleOutput struct {\n\tStep int\n}\n\ntype DagResult struct {\n\tStep1 SimpleOutput\n\tStep2 SimpleOutput\n}\n\nfunc DagWorkflow(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[DagInput, DagResult] {\n\t// > Declaring a Workflow\n\tsimple := factory.NewWorkflow[DagInput, DagResult](\n\t\tcreate.WorkflowCreateOpts[DagInput]{\n\t\t\tName: "simple-dag",\n\n\t\t},\n\t\thatchet,\n\t)\n\n\t// > Defining a Task\n\tsimple.Task(\n\t\tcreate.WorkflowTask[DagInput, DagResult]{\n\t\t\tName: "step",\n\t\t}, func(ctx worker.HatchetContext, input DagInput) (interface{}, error) {\n\t\t\treturn &SimpleOutput{\n\t\t\t\tStep: 1,\n\t\t\t}, nil\n\t\t},\n\t)\n\n\t// > Adding a Task with a parent\n\tstep1 := simple.Task(\n\t\tcreate.WorkflowTask[DagInput, DagResult]{\n\t\t\tName: "step-1",\n\t\t}, func(ctx worker.HatchetContext, input DagInput) (interface{}, error) {\n\t\t\treturn &SimpleOutput{\n\t\t\t\tStep: 1,\n\t\t\t}, nil\n\t\t},\n\t)\n\n\tsimple.Task(\n\t\tcreate.WorkflowTask[DagInput, DagResult]{\n\t\t\tName: "step-2",\n\t\t\tParents: []create.NamedTask{\n\t\t\t\tstep1,\n\t\t\t},\n\t\t}, func(ctx worker.HatchetContext, input DagInput) (interface{}, error) {\n\t\t\t// Get the output of the parent task\n\t\t\tvar step1Output SimpleOutput\n\t\t\terr := ctx.ParentOutput(step1, &step1Output)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\treturn &SimpleOutput{\n\t\t\t\tStep: 2,\n\t\t\t}, nil\n\t\t},\n\t)\n\n\treturn simple\n}\n',
source: 'out/go/workflows/dag.go',
blocks: {
declaring_a_workflow: {
start: 26,
stop: 32,
},
defining_a_task: {
start: 35,
stop: 43,
},
adding_a_task_with_a_parent: {
start: 46,
stop: 74,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,21 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype DurableEventInput struct {\n\tMessage string\n}\n\ntype EventData struct {\n\tMessage string\n}\n\ntype DurableEventOutput struct {\n\tData EventData\n}\n\nfunc DurableEvent(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[DurableEventInput, DurableEventOutput] {\n\t// > Durable Event\n\tdurableEventTask := factory.NewDurableTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "durable-event",\n\t\t},\n\t\tfunc(ctx worker.DurableHatchetContext, input DurableEventInput) (*DurableEventOutput, error) {\n\t\t\teventData, err := ctx.WaitForEvent("user:update", "")\n\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tv := EventData{}\n\t\t\terr = eventData.Unmarshal(&v)\n\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\treturn &DurableEventOutput{\n\t\t\t\tData: v,\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\tfactory.NewDurableTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "durable-event",\n\t\t},\n\t\tfunc(ctx worker.DurableHatchetContext, input DurableEventInput) (*DurableEventOutput, error) {\n\t\t\t// > Durable Event With Filter\n\t\t\teventData, err := ctx.WaitForEvent("user:update", "input.user_id == \'1234\'")\n\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tv := EventData{}\n\t\t\terr = eventData.Unmarshal(&v)\n\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\treturn &DurableEventOutput{\n\t\t\t\tData: v,\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn durableEventTask\n}\n',
source: 'out/go/workflows/durable-event.go',
blocks: {
durable_event: {
start: 25,
stop: 48,
},
durable_event_with_filter: {
start: 56,
stop: 56,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,17 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"strings"\n\t"time"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype DurableSleepInput struct {\n\tMessage string\n}\n\ntype DurableSleepOutput struct {\n\tTransformedMessage string\n}\n\nfunc DurableSleep(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[DurableSleepInput, DurableSleepOutput] {\n\t// > Durable Sleep\n\tsimple := factory.NewDurableTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "durable-sleep",\n\t\t},\n\t\tfunc(ctx worker.DurableHatchetContext, input DurableSleepInput) (*DurableSleepOutput, error) {\n\t\t\t_, err := ctx.SleepFor(10 * time.Second)\n\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\treturn &DurableSleepOutput{\n\t\t\t\tTransformedMessage: strings.ToLower(input.Message),\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn simple\n}\n',
source: 'out/go/workflows/durable-sleep.go',
blocks: {
durable_sleep: {
start: 24,
stop: 40,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,37 @@
import cancellations from './cancellations';
import child_workflows from './child-workflows';
import complex_conditions from './complex-conditions';
import concurrency_rr from './concurrency-rr';
import dag_with_conditions from './dag-with-conditions';
import dag from './dag';
import durable_event from './durable-event';
import durable_sleep from './durable-sleep';
import non_retryable_error from './non-retryable-error';
import on_cron from './on-cron';
import on_event from './on-event';
import on_failure from './on-failure';
import priority from './priority';
import ratelimit from './ratelimit';
import retries from './retries';
import simple from './simple';
import sticky from './sticky';
import timeouts from './timeouts';
export { cancellations };
export { child_workflows };
export { complex_conditions };
export { concurrency_rr };
export { dag_with_conditions };
export { dag };
export { durable_event };
export { durable_sleep };
export { non_retryable_error };
export { on_cron };
export { on_event };
export { on_failure };
export { priority };
export { ratelimit };
export { retries };
export { simple };
export { sticky };
export { timeouts };

View File

@@ -0,0 +1,17 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"errors"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype NonRetryableInput struct{}\ntype NonRetryableResult struct{}\n\n// NonRetryableError returns a workflow which throws a non-retryable error\nfunc NonRetryableError(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[NonRetryableInput, NonRetryableResult] {\n\t// > Non Retryable Error\n\tretries := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "non-retryable-task",\n\t\t\tRetries: 3,\n\t\t}, func(ctx worker.HatchetContext, input NonRetryableInput) (*NonRetryableResult, error) {\n\t\t\treturn nil, worker.NewNonRetryableError(errors.New("intentional failure"))\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn retries\n}\n',
source: 'out/go/workflows/non-retryable-error.go',
blocks: {
non_retryable_error: {
start: 19,
stop: 27,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,17 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"strings"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype OnCronInput struct {\n\tMessage string `json:"Message"`\n}\n\ntype JobResult struct {\n\tTransformedMessage string `json:"TransformedMessage"`\n}\n\ntype OnCronOutput struct {\n\tJob JobResult `json:"job"`\n}\n\n// > Workflow Definition Cron Trigger\nfunc OnCron(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[OnCronInput, OnCronOutput] {\n\t// Create a standalone task that transforms a message\n\tcronTask := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "on-cron-task",\n\t\t\t// 👀 add a cron expression\n\t\t\tOnCron: []string{"0 0 * * *"}, // Run every day at midnight\n\t\t},\n\t\tfunc(ctx worker.HatchetContext, input OnCronInput) (*OnCronOutput, error) {\n\t\t\treturn &OnCronOutput{\n\t\t\t\tJob: JobResult{\n\t\t\t\t\tTransformedMessage: strings.ToLower(input.Message),\n\t\t\t\t},\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn cronTask\n}\n\n',
source: 'out/go/workflows/on-cron.go',
blocks: {
workflow_definition_cron_trigger: {
start: 26,
stop: 46,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,25 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"fmt"\n\t"strings"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\t"github.com/hatchet-dev/hatchet/pkg/client/types"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype EventInput struct {\n\tMessage string\n}\n\ntype LowerTaskOutput struct {\n\tTransformedMessage string\n}\n\ntype UpperTaskOutput struct {\n\tTransformedMessage string\n}\n\n// > Run workflow on event\nconst SimpleEvent = "simple-event:create"\n\nfunc Lower(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[EventInput, LowerTaskOutput] {\n\treturn factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "lower",\n\t\t\t// 👀 Declare the event that will trigger the workflow\n\t\t\tOnEvents: []string{SimpleEvent},\n\t\t}, func(ctx worker.HatchetContext, input EventInput) (*LowerTaskOutput, error) {\n\t\t\t// Transform the input message to lowercase\n\t\t\treturn &LowerTaskOutput{\n\t\t\t\tTransformedMessage: strings.ToLower(input.Message),\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n}\n\n\n// > Accessing the filter payload\nfunc accessFilterPayload(ctx worker.HatchetContext, input EventInput) (*LowerTaskOutput, error) {\n\tfmt.Println(ctx.FilterPayload())\n\treturn &LowerTaskOutput{\n\t\tTransformedMessage: strings.ToLower(input.Message),\n\t}, nil\n}\n\n\n// > Declare with filter\nfunc LowerWithFilter(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[EventInput, LowerTaskOutput] {\n\treturn factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "lower",\n\t\t\t// 👀 Declare the event that will trigger the workflow\n\t\t\tOnEvents: []string{SimpleEvent},\n\t\t\tDefaultFilters: []types.DefaultFilter{{\n\t\t\t\tExpression: "true",\n\t\t\t\tScope: "example-scope",\n\t\t\t\tPayload: map[string]interface{}{\n\t\t\t\t\t"main_character": "Anna",\n\t\t\t\t\t"supporting_character": "Stiva",\n\t\t\t\t\t"location": "Moscow"},\n\t\t\t}},\n\t\t}, accessFilterPayload,\n\t\thatchet,\n\t)\n}\n\n\nfunc Upper(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[EventInput, UpperTaskOutput] {\n\treturn factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "upper",\n\t\t\tOnEvents: []string{SimpleEvent},\n\t\t},\n\t\tfunc(ctx worker.HatchetContext, input EventInput) (*UpperTaskOutput, error) {\n\t\t\treturn &UpperTaskOutput{\n\t\t\t\tTransformedMessage: strings.ToUpper(input.Message),\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n}\n',
source: 'out/go/workflows/on-event.go',
blocks: {
run_workflow_on_event: {
start: 28,
stop: 45,
},
accessing_the_filter_payload: {
start: 48,
stop: 54,
},
declare_with_filter: {
start: 57,
stop: 75,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"errors"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype AlwaysFailsOutput struct {\n\tTransformedMessage string\n}\n\ntype OnFailureOutput struct {\n\tFailureRan bool\n}\n\ntype OnFailureSuccessResult struct {\n\tAlwaysFails AlwaysFailsOutput\n}\n\nfunc OnFailure(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[any, OnFailureSuccessResult] {\n\n\tsimple := factory.NewWorkflow[any, OnFailureSuccessResult](\n\t\tcreate.WorkflowCreateOpts[any]{\n\t\t\tName: "on-failure",\n\t\t},\n\t\thatchet,\n\t)\n\n\tsimple.Task(\n\t\tcreate.WorkflowTask[any, OnFailureSuccessResult]{\n\t\t\tName: "AlwaysFails",\n\t\t},\n\t\tfunc(ctx worker.HatchetContext, _ any) (interface{}, error) {\n\t\t\treturn &AlwaysFailsOutput{\n\t\t\t\tTransformedMessage: "always fails",\n\t\t\t}, errors.New("always fails")\n\t\t},\n\t)\n\n\tsimple.OnFailure(\n\t\tcreate.WorkflowOnFailureTask[any, OnFailureSuccessResult]{},\n\t\tfunc(ctx worker.HatchetContext, _ any) (interface{}, error) {\n\t\t\treturn &OnFailureOutput{\n\t\t\t\tFailureRan: true,\n\t\t\t}, nil\n\t\t},\n\t)\n\n\treturn simple\n}\n',
source: 'out/go/workflows/on-failure.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,21 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"time"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype PriorityInput struct {\n\tUserId string `json:"userId"`\n}\n\ntype PriorityOutput struct {\n\tTransformedMessage string `json:"TransformedMessage"`\n}\n\ntype Result struct {\n\tStep PriorityOutput\n}\n\nfunc Priority(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[PriorityInput, Result] {\n\t// Create a standalone task that transforms a message\n\n\t// > Default priority\n\tdefaultPriority := int32(1)\n\n\tworkflow := factory.NewWorkflow[PriorityInput, Result](\n\t\tcreate.WorkflowCreateOpts[PriorityInput]{\n\t\t\tName: "priority",\n\t\t\tDefaultPriority: &defaultPriority,\n\t\t},\n\t\thatchet,\n\t)\n\n\t// > Defining a Task\n\tworkflow.Task(\n\t\tcreate.WorkflowTask[PriorityInput, Result]{\n\t\t\tName: "step",\n\t\t}, func(ctx worker.HatchetContext, input PriorityInput) (interface{}, error) {\n\t\t\ttime.Sleep(time.Second * 5)\n\t\t\treturn &PriorityOutput{\n\t\t\t\tTransformedMessage: input.UserId,\n\t\t\t}, nil\n\t\t},\n\t)\n\treturn workflow\n}\n\n',
source: 'out/go/workflows/priority.go',
blocks: {
default_priority: {
start: 29,
stop: 37,
},
defining_a_task: {
start: 40,
stop: 49,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,25 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"strings"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\t"github.com/hatchet-dev/hatchet/pkg/client/types"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/features"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype RateLimitInput struct {\n\tUserId string `json:"userId"`\n}\n\ntype RateLimitOutput struct {\n\tTransformedMessage string `json:"TransformedMessage"`\n}\n\nfunc upsertRateLimit(hatchet v1.HatchetClient) {\n\t// > Upsert Rate Limit\n\thatchet.RateLimits().Upsert(\n\t\tfeatures.CreateRatelimitOpts{\n\t\t\tKey: "api-service-rate-limit",\n\t\t\tLimit: 10,\n\t\t\tDuration: types.Second,\n\t\t},\n\t)\n}\n\n// > Static Rate Limit\nfunc StaticRateLimit(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[RateLimitInput, RateLimitOutput] {\n\t// Create a standalone task that transforms a message\n\n\t// define the parameters for the rate limit\n\trateLimitKey := "api-service-rate-limit"\n\tunits := 1\n\n\trateLimitTask := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "rate-limit-task",\n\t\t\t// 👀 add a static rate limit\n\t\t\tRateLimits: []*types.RateLimit{\n\t\t\t\t{\n\t\t\t\t\tKey: rateLimitKey,\n\t\t\t\t\tUnits: &units,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tfunc(ctx worker.HatchetContext, input RateLimitInput) (*RateLimitOutput, error) {\n\t\t\treturn &RateLimitOutput{\n\t\t\t\tTransformedMessage: strings.ToLower(input.UserId),\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn rateLimitTask\n}\n\n\n// > Dynamic Rate Limit\nfunc RateLimit(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[RateLimitInput, RateLimitOutput] {\n\t// Create a standalone task that transforms a message\n\n\t// define the parameters for the rate limit\n\texpression := "input.userId"\n\tunits := 1\n\tduration := types.Second\n\n\trateLimitTask := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "rate-limit-task",\n\t\t\t// 👀 add a dynamic rate limit\n\t\t\tRateLimits: []*types.RateLimit{\n\t\t\t\t{\n\t\t\t\t\tKeyExpr: &expression,\n\t\t\t\t\tUnits: &units,\n\t\t\t\t\tDuration: &duration,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tfunc(ctx worker.HatchetContext, input RateLimitInput) (*RateLimitOutput, error) {\n\t\t\treturn &RateLimitOutput{\n\t\t\t\tTransformedMessage: strings.ToLower(input.UserId),\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn rateLimitTask\n}\n\n',
source: 'out/go/workflows/ratelimit.go',
blocks: {
upsert_rate_limit: {
start: 25,
stop: 31,
},
static_rate_limit: {
start: 35,
stop: 63,
},
dynamic_rate_limit: {
start: 66,
stop: 96,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,25 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"errors"\n\t"fmt"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype RetriesInput struct{}\ntype RetriesResult struct{}\n\n// Simple retries example that always fails\nfunc Retries(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[RetriesInput, RetriesResult] {\n\t// > Simple Step Retries\n\tretries := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "retries-task",\n\t\t\tRetries: 3,\n\t\t}, func(ctx worker.HatchetContext, input RetriesInput) (*RetriesResult, error) {\n\t\t\treturn nil, errors.New("intentional failure")\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn retries\n}\n\ntype RetriesWithCountInput struct{}\ntype RetriesWithCountResult struct {\n\tMessage string `json:"message"`\n}\n\n// Retries example that succeeds after a certain number of retries\nfunc RetriesWithCount(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[RetriesWithCountInput, RetriesWithCountResult] {\n\t// > Retries with Count\n\tretriesWithCount := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "fail-twice-task",\n\t\t\tRetries: 3,\n\t\t}, func(ctx worker.HatchetContext, input RetriesWithCountInput) (*RetriesWithCountResult, error) {\n\t\t\t// Get the current retry count\n\t\t\tretryCount := ctx.RetryCount()\n\n\t\t\tfmt.Printf("Retry count: %d\\n", retryCount)\n\n\t\t\tif retryCount < 2 {\n\t\t\t\treturn nil, errors.New("intentional failure")\n\t\t\t}\n\n\t\t\treturn &RetriesWithCountResult{\n\t\t\t\tMessage: "success",\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn retriesWithCount\n}\n\ntype BackoffInput struct{}\ntype BackoffResult struct{}\n\n// Retries example with simple backoff (no configuration in this API version)\nfunc WithBackoff(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[BackoffInput, BackoffResult] {\n\t// > Retries with Backoff\n\twithBackoff := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "with-backoff-task",\n\t\t\t// 👀 Maximum number of seconds to wait between retries\n\t\t\tRetries: 3,\n\t\t\t// 👀 Factor to increase the wait time between retries.\n\t\t\tRetryBackoffFactor: 2,\n\t\t\t// 👀 Maximum number of seconds to wait between retries\n\t\t\t// This sequence will be 2s, 4s, 8s, 10s, 10s, 10s... due to the maxSeconds limit\n\t\t\tRetryMaxBackoffSeconds: 10,\n\t\t}, func(ctx worker.HatchetContext, input BackoffInput) (*BackoffResult, error) {\n\t\t\treturn nil, errors.New("intentional failure")\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn withBackoff\n}\n',
source: 'out/go/workflows/retries.go',
blocks: {
simple_step_retries: {
start: 20,
stop: 28,
},
retries_with_count: {
start: 41,
stop: 60,
},
retries_with_backoff: {
start: 71,
stop: 85,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,29 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"context"\n\t"fmt"\n\t"strings"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\tv1worker "github.com/hatchet-dev/hatchet/pkg/v1/worker"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype SimpleInput struct {\n\tMessage string\n}\ntype SimpleResult struct {\n\tTransformedMessage string\n}\n\nfunc Simple(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[SimpleInput, SimpleResult] {\n\n\t// Create a simple standalone task using the task factory\n\t// Note the use of typed generics for both input and output\n\n\t// > Declaring a Task\n\tsimple := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "simple-task",\n\t\t}, func(ctx worker.HatchetContext, input SimpleInput) (*SimpleResult, error) {\n\t\t\t// Transform the input message to lowercase\n\t\t\treturn &SimpleResult{\n\t\t\t\tTransformedMessage: strings.ToLower(input.Message),\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\t// Example of running a task\n\t_ = func() error {\n\t\t// > Running a Task\n\t\tresult, err := simple.Run(context.Background(), SimpleInput{Message: "Hello, World!"})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfmt.Println(result.TransformedMessage)\n\t\treturn nil\n\t}\n\n\t// Example of registering a task on a worker\n\t_ = func() error {\n\t\t// > Declaring a Worker\n\t\tw, err := hatchet.Worker(v1worker.WorkerOpts{\n\t\t\tName: "simple-worker",\n\t\t\tWorkflows: []workflow.WorkflowBase{\n\t\t\t\tsimple,\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = w.StartBlocking(context.Background())\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\n\treturn simple\n}\n\nfunc ParentTask(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[SimpleInput, SimpleResult] {\n\n\t// > Spawning Tasks from within a Task\n\tsimple := Simple(hatchet)\n\n\tparent := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "parent-task",\n\t\t}, func(ctx worker.HatchetContext, input SimpleInput) (*SimpleResult, error) {\n\n\t\t\t// Run the child task\n\t\t\tchild, err := workflow.RunChildWorkflow(ctx, simple, SimpleInput{Message: input.Message})\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\t// Transform the input message to lowercase\n\t\t\treturn &SimpleResult{\n\t\t\t\tTransformedMessage: child.TransformedMessage,\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn parent\n}\n',
source: 'out/go/workflows/simple.go',
blocks: {
declaring_a_task: {
start: 29,
stop: 39,
},
running_a_task: {
start: 44,
stop: 48,
},
declaring_a_worker: {
start: 55,
stop: 67,
},
spawning_tasks_from_within_a_task: {
start: 77,
stop: 96,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"fmt"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype StickyInput struct{}\n\ntype StickyResult struct {\n\tResult string `json:"result"`\n}\n\ntype StickyDagResult struct {\n\tStickyTask1 StickyResult `json:"sticky-task-1"`\n\tStickyTask2 StickyResult `json:"sticky-task-2"`\n}\n\nfunc StickyDag(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[StickyInput, StickyDagResult] {\n\tstickyDag := factory.NewWorkflow[StickyInput, StickyDagResult](\n\t\tcreate.WorkflowCreateOpts[StickyInput]{\n\t\t\tName: "sticky-dag",\n\t\t},\n\t\thatchet,\n\t)\n\n\tstickyDag.Task(\n\t\tcreate.WorkflowTask[StickyInput, StickyDagResult]{\n\t\t\tName: "sticky-task",\n\t\t},\n\t\tfunc(ctx worker.HatchetContext, input StickyInput) (interface{}, error) {\n\t\t\tworkerId := ctx.Worker().ID()\n\n\t\t\treturn &StickyResult{\n\t\t\t\tResult: workerId,\n\t\t\t}, nil\n\t\t},\n\t)\n\n\tstickyDag.Task(\n\t\tcreate.WorkflowTask[StickyInput, StickyDagResult]{\n\t\t\tName: "sticky-task-2",\n\t\t},\n\t\tfunc(ctx worker.HatchetContext, input StickyInput) (interface{}, error) {\n\t\t\tworkerId := ctx.Worker().ID()\n\n\t\t\treturn &StickyResult{\n\t\t\t\tResult: workerId,\n\t\t\t}, nil\n\t\t},\n\t)\n\n\treturn stickyDag\n}\n\nfunc Sticky(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[StickyInput, StickyResult] {\n\tsticky := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "sticky-task",\n\t\t\tRetries: 3,\n\t\t}, func(ctx worker.HatchetContext, input StickyInput) (*StickyResult, error) {\n\t\t\t// Run a child workflow on the same worker\n\t\t\tchildWorkflow := Child(hatchet)\n\t\t\tsticky := true\n\t\t\tchildResult, err := childWorkflow.RunAsChild(ctx, ChildInput{N: 1}, workflow.RunAsChildOpts{\n\t\t\t\tSticky: &sticky,\n\t\t\t})\n\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\treturn &StickyResult{\n\t\t\t\tResult: fmt.Sprintf("child-result-%d", childResult.Value),\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn sticky\n}\n',
source: 'out/go/workflows/sticky.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,21 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package v1_workflows\n\nimport (\n\t"errors"\n\t"time"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client/create"\n\tv1 "github.com/hatchet-dev/hatchet/pkg/v1"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/factory"\n\t"github.com/hatchet-dev/hatchet/pkg/v1/workflow"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype TimeoutInput struct{}\ntype TimeoutResult struct {\n\tCompleted bool\n}\n\nfunc Timeout(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[TimeoutInput, TimeoutResult] {\n\n\t// > Execution Timeout\n\t// Create a task with a timeout of 3 seconds that tries to sleep for 10 seconds\n\ttimeout := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "timeout-task",\n\t\t\tExecutionTimeout: 3 * time.Second, // Task will timeout after 3 seconds\n\t\t}, func(ctx worker.HatchetContext, input TimeoutInput) (*TimeoutResult, error) {\n\t\t\t// Sleep for 10 seconds\n\t\t\ttime.Sleep(10 * time.Second)\n\n\t\t\t// Check if the context was cancelled due to timeout\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn nil, errors.New("TASK TIMED OUT")\n\t\t\tdefault:\n\t\t\t\t// Continue execution\n\t\t\t}\n\n\t\t\treturn &TimeoutResult{\n\t\t\t\tCompleted: true,\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn timeout\n}\n\nfunc RefreshTimeout(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[TimeoutInput, TimeoutResult] {\n\n\t// > Refresh Timeout\n\ttimeout := factory.NewTask(\n\t\tcreate.StandaloneTask{\n\t\t\tName: "timeout-task",\n\t\t\tExecutionTimeout: 3 * time.Second, // Task will timeout after 3 seconds\n\t\t}, func(ctx worker.HatchetContext, input TimeoutInput) (*TimeoutResult, error) {\n\n\t\t\t// Refresh the timeout by 10 seconds (new timeout will be 13 seconds)\n\t\t\tctx.RefreshTimeout("10s")\n\n\t\t\t// Sleep for 10 seconds\n\t\t\ttime.Sleep(10 * time.Second)\n\n\t\t\t// Check if the context was cancelled due to timeout\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn nil, errors.New("TASK TIMED OUT")\n\t\t\tdefault:\n\t\t\t\t// Continue execution\n\t\t\t}\n\n\t\t\treturn &TimeoutResult{\n\t\t\t\tCompleted: true,\n\t\t\t}, nil\n\t\t},\n\t\thatchet,\n\t)\n\n\treturn timeout\n}\n',
source: 'out/go/workflows/timeouts.go',
blocks: {
execution_timeout: {
start: 22,
stop: 44,
},
refresh_timeout: {
start: 52,
stop: 77,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,5 @@
import main from './main';
import run from './run';
export { main };
export { run };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"fmt"\n\n\t"github.com/joho/godotenv"\n\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n)\n\ntype userCreateEvent struct {\n\tUsername string `json:"username"`\n\tUserID string `json:"user_id"`\n\tData map[string]string `json:"data"`\n}\n\ntype stepOneOutput struct {\n\tMessage string `json:"message"`\n}\n\nfunc main() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tch := cmdutils.InterruptChan()\n\tcleanup, err := run()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t<-ch\n\n\tif err := cleanup(); err != nil {\n\t\tpanic(fmt.Errorf("cleanup() error = %v", err))\n\t}\n}\n',
source: 'out/go/z_v0/assignment-affinity/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"log"\n\t"time"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/client/types"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\nfunc run() (func() error, error) {\n\tc, err := client.New()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error creating client: %w", err)\n\t}\n\n\tw, err := worker.NewWorker(\n\t\tworker.WithClient(\n\t\t\tc,\n\t\t),\n\t\tworker.WithLabels(map[string]interface{}{\n\t\t\t"model": "fancy-ai-model-v2",\n\t\t\t"memory": 1024,\n\t\t}),\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error creating worker: %w", err)\n\t}\n\n\terr = w.RegisterWorkflow(\n\t\t&worker.WorkflowJob{\n\t\t\tOn: worker.Events("user:create:affinity"),\n\t\t\tName: "affinity",\n\t\t\tDescription: "affinity",\n\t\t\tSteps: []*worker.WorkflowStep{\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOneOutput, err error) {\n\n\t\t\t\t\tmodel := ctx.Worker().GetLabels()["model"]\n\n\t\t\t\t\tif model != "fancy-ai-model-v3" {\n\t\t\t\t\t\tctx.Worker().UpsertLabels(map[string]interface{}{\n\t\t\t\t\t\t\t"model": nil,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t// Do something to load the model\n\t\t\t\t\t\tctx.Worker().UpsertLabels(map[string]interface{}{\n\t\t\t\t\t\t\t"model": "fancy-ai-model-v3",\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\n\t\t\t\t\treturn &stepOneOutput{\n\t\t\t\t\t\tMessage: ctx.Worker().ID(),\n\t\t\t\t\t}, nil\n\t\t\t\t}).\n\t\t\t\t\tSetName("step-one").\n\t\t\t\t\tSetDesiredLabels(map[string]*types.DesiredWorkerLabel{\n\t\t\t\t\t\t"model": {\n\t\t\t\t\t\t\tValue: "fancy-ai-model-v3",\n\t\t\t\t\t\t\tWeight: 10,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t"memory": {\n\t\t\t\t\t\t\tValue: 512,\n\t\t\t\t\t\t\tRequired: true,\n\t\t\t\t\t\t\tComparator: types.ComparatorPtr(types.WorkerLabelComparator_GREATER_THAN),\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error registering workflow: %w", err)\n\t}\n\n\tgo func() {\n\t\tlog.Printf("pushing event")\n\n\t\ttestEvent := userCreateEvent{\n\t\t\tUsername: "echo-test",\n\t\t\tUserID: "1234",\n\t\t\tData: map[string]string{\n\t\t\t\t"test": "test",\n\t\t\t},\n\t\t}\n\n\t\t// push an event\n\t\terr := c.Event().Push(\n\t\t\tcontext.Background(),\n\t\t\t"user:create:affinity",\n\t\t\ttestEvent,\n\t\t)\n\t\tif err != nil {\n\t\t\tpanic(fmt.Errorf("error pushing event: %w", err))\n\t\t}\n\n\t\ttime.Sleep(10 * time.Second)\n\t}()\n\n\tcleanup, err := w.Start()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error starting worker: %w", err)\n\t}\n\n\treturn cleanup, nil\n}\n',
source: 'out/go/z_v0/assignment-affinity/run.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,5 @@
import main from './main';
import run from './run';
export { main };
export { run };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"fmt"\n\n\t"github.com/joho/godotenv"\n\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n)\n\ntype userCreateEvent struct {\n\tUsername string `json:"username"`\n\tUserID string `json:"user_id"`\n\tData map[string]string `json:"data"`\n}\n\ntype stepOneOutput struct {\n\tMessage string `json:"message"`\n}\n\nfunc main() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tch := cmdutils.InterruptChan()\n\tcleanup, err := run()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t<-ch\n\n\tif err := cleanup(); err != nil {\n\t\tpanic(fmt.Errorf("cleanup() error = %v", err))\n\t}\n}\n',
source: 'out/go/z_v0/assignment-sticky/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,21 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"log"\n\t"time"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/client/types"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\nfunc run() (func() error, error) {\n\tc, err := client.New()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error creating client: %w", err)\n\t}\n\n\tw, err := worker.NewWorker(\n\t\tworker.WithClient(\n\t\t\tc,\n\t\t),\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error creating worker: %w", err)\n\t}\n\n\t// > StickyWorker\n\n\terr = w.RegisterWorkflow(\n\t\t&worker.WorkflowJob{\n\t\t\tOn: worker.Events("user:create:sticky"),\n\t\t\tName: "sticky",\n\t\t\tDescription: "sticky",\n\t\t\t// 👀 Specify a sticky strategy when declaring the workflow\n\t\t\tStickyStrategy: types.StickyStrategyPtr(types.StickyStrategy_HARD),\n\t\t\tSteps: []*worker.WorkflowStep{\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOneOutput, err error) {\n\n\t\t\t\t\tsticky := true\n\n\t\t\t\t\t_, err = ctx.SpawnWorkflow("sticky-child", nil, &worker.SpawnWorkflowOpts{\n\t\t\t\t\t\tSticky: &sticky,\n\t\t\t\t\t})\n\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf("error spawning workflow: %w", err)\n\t\t\t\t\t}\n\n\t\t\t\t\treturn &stepOneOutput{\n\t\t\t\t\t\tMessage: ctx.Worker().ID(),\n\t\t\t\t\t}, nil\n\t\t\t\t}).SetName("step-one"),\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOneOutput, err error) {\n\t\t\t\t\treturn &stepOneOutput{\n\t\t\t\t\t\tMessage: ctx.Worker().ID(),\n\t\t\t\t\t}, nil\n\t\t\t\t}).SetName("step-two").AddParents("step-one"),\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOneOutput, err error) {\n\t\t\t\t\treturn &stepOneOutput{\n\t\t\t\t\t\tMessage: ctx.Worker().ID(),\n\t\t\t\t\t}, nil\n\t\t\t\t}).SetName("step-three").AddParents("step-two"),\n\t\t\t},\n\t\t},\n\t)\n\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error registering workflow: %w", err)\n\t}\n\n\t// > StickyChild\n\n\terr = w.RegisterWorkflow(\n\t\t&worker.WorkflowJob{\n\t\t\tOn: worker.NoTrigger(),\n\t\t\tName: "sticky-child",\n\t\t\tDescription: "sticky",\n\t\t\tSteps: []*worker.WorkflowStep{\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOneOutput, err error) {\n\t\t\t\t\treturn &stepOneOutput{\n\t\t\t\t\t\tMessage: ctx.Worker().ID(),\n\t\t\t\t\t}, nil\n\t\t\t\t}).SetName("step-one"),\n\t\t\t},\n\t\t},\n\t)\n\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error registering workflow: %w", err)\n\t}\n\n\tgo func() {\n\t\tlog.Printf("pushing event")\n\n\t\ttestEvent := userCreateEvent{\n\t\t\tUsername: "echo-test",\n\t\t\tUserID: "1234",\n\t\t\tData: map[string]string{\n\t\t\t\t"test": "test",\n\t\t\t},\n\t\t}\n\n\t\t// push an event\n\t\terr := c.Event().Push(\n\t\t\tcontext.Background(),\n\t\t\t"user:create:sticky",\n\t\t\ttestEvent,\n\t\t)\n\t\tif err != nil {\n\t\t\tpanic(fmt.Errorf("error pushing event: %w", err))\n\t\t}\n\n\t\ttime.Sleep(10 * time.Second)\n\t}()\n\n\tcleanup, err := w.Start()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error starting worker: %w", err)\n\t}\n\n\treturn cleanup, nil\n}\n',
source: 'out/go/z_v0/assignment-sticky/run.go',
blocks: {
stickyworker: {
start: 30,
stop: 68,
},
stickychild: {
start: 75,
stop: 90,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import main from './main';
export { main };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"log"\n\n\t"github.com/joho/godotenv"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype userCreateEvent struct {\n\tUsername string `json:"username"`\n\tUserID string `json:"user_id"`\n\tData map[string]string `json:"data"`\n}\n\ntype stepOneOutput struct {\n\tMessage string `json:"message"`\n}\n\nfunc main() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t_, err = run()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n}\n\nfunc run() (func() error, error) {\n\tc, err := client.New()\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error creating client: %w", err)\n\t}\n\n\tw, err := worker.NewWorker(\n\t\tworker.WithClient(\n\t\t\tc,\n\t\t),\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error creating worker: %w", err)\n\t}\n\n\ttestSvc := w.NewService("test")\n\n\terr = testSvc.RegisterWorkflow(\n\t\t&worker.WorkflowJob{\n\t\t\tOn: worker.Events("user:create:bulk"),\n\t\t\tName: "bulk",\n\t\t\tDescription: "This runs after an update to the user model.",\n\t\t\tSteps: []*worker.WorkflowStep{\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOneOutput, err error) {\n\t\t\t\t\tinput := &userCreateEvent{}\n\n\t\t\t\t\terr = ctx.WorkflowInput(input)\n\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\n\t\t\t\t\tlog.Printf("step-one")\n\n\t\t\t\t\treturn &stepOneOutput{\n\t\t\t\t\t\tMessage: "Username is: " + input.Username,\n\t\t\t\t\t}, nil\n\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error registering workflow: %w", err)\n\t}\n\n\tvar events []client.EventWithAdditionalMetadata\n\n\t// 20000 times to test the bulk push\n\n\tfor i := 0; i < 20000; i++ {\n\t\ttestEvent := userCreateEvent{\n\t\t\tUsername: "echo-test",\n\t\t\tUserID: "1234 " + fmt.Sprint(i),\n\t\t\tData: map[string]string{\n\t\t\t\t"test": "test " + fmt.Sprint(i),\n\t\t\t},\n\t\t}\n\t\tevents = append(events, client.EventWithAdditionalMetadata{\n\t\t\tEvent: testEvent,\n\t\t\tAdditionalMetadata: map[string]string{"hello": "world " + fmt.Sprint(i)},\n\t\t\tKey: "user:create:bulk",\n\t\t})\n\t}\n\n\tlog.Printf("pushing event user:create:bulk")\n\n\terr = c.Event().BulkPush(\n\t\tcontext.Background(),\n\t\tevents,\n\t)\n\tif err != nil {\n\t\tpanic(fmt.Errorf("error pushing event: %w", err))\n\t}\n\n\treturn nil, nil\n\n}\n',
source: 'out/go/z_v0/bulk_imports/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,5 @@
import main from './main';
import run from './run';
export { main };
export { run };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"fmt"\n\t"log"\n\t"time"\n\n\t"github.com/joho/godotenv"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/client/types"\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype userCreateEvent struct {\n\tUsername string `json:"username"`\n\tUserID string `json:"user_id"`\n\tData map[string]string `json:"data"`\n}\n\ntype stepOneOutput struct {\n\tMessage string `json:"message"`\n}\n\nfunc main() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tch := cmdutils.InterruptChan()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tworkflowName := "simple-bulk-workflow"\n\tc, err := client.New()\n\n\tif err != nil {\n\t\tpanic(fmt.Errorf("error creating client: %w", err))\n\t}\n\n\t_, err = registerWorkflow(c, workflowName)\n\n\tif err != nil {\n\t\tpanic(fmt.Errorf("error registering workflow: %w", err))\n\t}\n\n\tquantity := 999\n\n\toverallStart := time.Now()\n\titerations := 10\n\tfor i := 0; i < iterations; i++ {\n\t\tstartTime := time.Now()\n\n\t\tfmt.Printf("Running the %dth bulk workflow \\n", i)\n\n\t\terr = runBulk(workflowName, quantity)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfmt.Printf("Time taken to queue %dth bulk workflow: %v\\n", i, time.Since(startTime))\n\t}\n\tfmt.Println("Overall time taken: ", time.Since(overallStart))\n\tfmt.Printf("That is %d workflows per second\\n", int(float64(quantity*iterations)/time.Since(overallStart).Seconds()))\n\tfmt.Println("Starting the worker")\n\n\t// err = runSingles(workflowName, quantity)\n\t// if err != nil {\n\t// \tpanic(err)\n\t// }\n\n\tif err != nil {\n\t\tpanic(fmt.Errorf("error creating client: %w", err))\n\t}\n\n\t// I want to start the wofklow worker here\n\n\tw, err := registerWorkflow(c, workflowName)\n\tif err != nil {\n\t\tpanic(fmt.Errorf("error creating worker: %w", err))\n\t}\n\n\tcleanup, err := w.Start()\n\tfmt.Println("Starting the worker")\n\n\tif err != nil {\n\t\tpanic(fmt.Errorf("error starting worker: %w", err))\n\t}\n\n\t<-ch\n\n\tif err := cleanup(); err != nil {\n\t\tpanic(fmt.Errorf("error cleaning up: %w", err))\n\t}\n\n}\n\nfunc getConcurrencyKey(ctx worker.HatchetContext) (string, error) {\n\treturn "my-key", nil\n}\n\nfunc registerWorkflow(c client.Client, workflowName string) (w *worker.Worker, err error) {\n\n\tw, err = worker.NewWorker(\n\t\tworker.WithClient(\n\t\t\tc,\n\t\t),\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error creating worker: %w", err)\n\t}\n\n\terr = w.RegisterWorkflow(\n\t\t&worker.WorkflowJob{\n\t\t\tOn: worker.Events("user:create:bulk-simple"),\n\t\t\tName: workflowName,\n\t\t\tConcurrency: worker.Concurrency(getConcurrencyKey).MaxRuns(200).LimitStrategy(types.GroupRoundRobin),\n\t\t\tDescription: "This runs after an update to the user model.",\n\t\t\tSteps: []*worker.WorkflowStep{\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOneOutput, err error) {\n\t\t\t\t\tinput := &userCreateEvent{}\n\n\t\t\t\t\terr = ctx.WorkflowInput(input)\n\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\n\t\t\t\t\tlog.Printf("step-one")\n\n\t\t\t\t\treturn &stepOneOutput{\n\t\t\t\t\t\tMessage: "Username is: " + input.Username,\n\t\t\t\t\t}, nil\n\t\t\t\t},\n\t\t\t\t).SetName("step-one"),\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOneOutput, err error) {\n\t\t\t\t\tinput := &stepOneOutput{}\n\t\t\t\t\terr = ctx.StepOutput("step-one", input)\n\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\n\t\t\t\t\tlog.Printf("step-two")\n\n\t\t\t\t\treturn &stepOneOutput{\n\t\t\t\t\t\tMessage: "Above message is: " + input.Message,\n\t\t\t\t\t}, nil\n\t\t\t\t}).SetName("step-two").AddParents("step-one"),\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error registering workflow: %w", err)\n\t}\n\treturn w, nil\n}\n',
source: 'out/go/z_v0/bulk_workflows/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"fmt"\n\t"log"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n)\n\nfunc runBulk(workflowName string, quantity int) error {\n\tc, err := client.New()\n\tif err != nil {\n\t\treturn fmt.Errorf("error creating client: %w", err)\n\t}\n\n\tlog.Printf("pushing %d workflows in bulk", quantity)\n\n\tvar workflows []*client.WorkflowRun\n\tfor i := 0; i < quantity; i++ {\n\t\tdata := map[string]interface{}{\n\t\t\t"username": fmt.Sprintf("echo-test-%d", i),\n\t\t\t"user_id": fmt.Sprintf("1234-%d", i),\n\t\t}\n\t\tworkflows = append(workflows, &client.WorkflowRun{\n\t\t\tName: workflowName,\n\t\t\tInput: data,\n\t\t\tOptions: []client.RunOptFunc{\n\t\t\t\t// setting a dedupe key so these shouldn\'t all run\n\t\t\t\tclient.WithRunMetadata(map[string]interface{}{\n\t\t\t\t\t// "dedupe": "dedupe1",\n\t\t\t\t}),\n\t\t\t},\n\t\t})\n\n\t}\n\n\touts, err := c.Admin().BulkRunWorkflow(workflows)\n\tif err != nil {\n\t\tpanic(fmt.Errorf("error pushing event: %w", err))\n\t}\n\n\tfor _, out := range outs {\n\t\tlog.Printf("workflow run id: %v", out)\n\t}\n\n\treturn nil\n\n}\n\nfunc runSingles(workflowName string, quantity int) error {\n\tc, err := client.New()\n\tif err != nil {\n\t\treturn fmt.Errorf("error creating client: %w", err)\n\t}\n\n\tlog.Printf("pushing %d single workflows", quantity)\n\n\tvar workflows []*client.WorkflowRun\n\tfor i := 0; i < quantity; i++ {\n\t\tdata := map[string]interface{}{\n\t\t\t"username": fmt.Sprintf("echo-test-%d", i),\n\t\t\t"user_id": fmt.Sprintf("1234-%d", i),\n\t\t}\n\t\tworkflows = append(workflows, &client.WorkflowRun{\n\t\t\tName: workflowName,\n\t\t\tInput: data,\n\t\t\tOptions: []client.RunOptFunc{\n\t\t\t\tclient.WithRunMetadata(map[string]interface{}{\n\t\t\t\t\t// "dedupe": "dedupe1",\n\t\t\t\t}),\n\t\t\t},\n\t\t})\n\t}\n\n\tfor _, wf := range workflows {\n\n\t\tgo func() {\n\t\t\tout, err := c.Admin().RunWorkflow(wf.Name, wf.Input, wf.Options...)\n\t\t\tif err != nil {\n\t\t\t\tpanic(fmt.Errorf("error pushing event: %w", err))\n\t\t\t}\n\n\t\t\tlog.Printf("workflow run id: %v", out)\n\t\t}()\n\n\t}\n\n\treturn nil\n}\n',
source: 'out/go/z_v0/bulk_workflows/run.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,5 @@
import main from './main';
import run from './run';
export { main };
export { run };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"fmt"\n\n\t"github.com/joho/godotenv"\n\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n)\n\ntype userCreateEvent struct {\n\tUsername string `json:"username"`\n\tUserID string `json:"user_id"`\n\tData map[string]string `json:"data"`\n}\n\ntype stepOneOutput struct {\n\tMessage string `json:"message"`\n}\n\nfunc main() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tevents := make(chan string, 50)\n\tch := cmdutils.InterruptChan()\n\tcleanup, err := run(events)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t<-ch\n\n\tif err := cleanup(); err != nil {\n\t\tpanic(fmt.Errorf("cleanup() error = %v", err))\n\t}\n}\n',
source: 'out/go/z_v0/cancellation/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"log"\n\t"time"\n\n\t"github.com/google/uuid"\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/client/rest"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\nfunc run(events chan<- string) (func() error, error) {\n\tc, err := client.New()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error creating client: %w", err)\n\t}\n\n\tw, err := worker.NewWorker(\n\t\tworker.WithClient(\n\t\t\tc,\n\t\t),\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error creating worker: %w", err)\n\t}\n\n\terr = w.RegisterWorkflow(\n\t\t&worker.WorkflowJob{\n\t\t\tOn: worker.Events("user:create:cancellation"),\n\t\t\tName: "cancellation",\n\t\t\tDescription: "cancellation",\n\t\t\tSteps: []*worker.WorkflowStep{\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOneOutput, err error) {\n\t\t\t\t\tselect {\n\t\t\t\t\tcase <-ctx.Done():\n\t\t\t\t\t\tevents <- "done"\n\t\t\t\t\t\tlog.Printf("context cancelled")\n\t\t\t\t\t\treturn nil, nil\n\t\t\t\t\tcase <-time.After(30 * time.Second):\n\t\t\t\t\t\tlog.Printf("workflow never cancelled")\n\t\t\t\t\t\treturn &stepOneOutput{\n\t\t\t\t\t\t\tMessage: "done",\n\t\t\t\t\t\t}, nil\n\t\t\t\t\t}\n\t\t\t\t}).SetName("step-one"),\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error registering workflow: %w", err)\n\t}\n\n\tgo func() {\n\t\tlog.Printf("pushing event")\n\n\t\ttestEvent := userCreateEvent{\n\t\t\tUsername: "echo-test",\n\t\t\tUserID: "1234",\n\t\t\tData: map[string]string{\n\t\t\t\t"test": "test",\n\t\t\t},\n\t\t}\n\n\t\t// push an event\n\t\terr := c.Event().Push(\n\t\t\tcontext.Background(),\n\t\t\t"user:create:cancellation",\n\t\t\ttestEvent,\n\t\t)\n\t\tif err != nil {\n\t\t\tpanic(fmt.Errorf("error pushing event: %w", err))\n\t\t}\n\n\t\ttime.Sleep(10 * time.Second)\n\n\t\tworkflowName := "cancellation"\n\n\t\tworkflows, err := c.API().WorkflowListWithResponse(context.Background(), uuid.MustParse(c.TenantId()), &rest.WorkflowListParams{\n\t\t\tName: &workflowName,\n\t\t})\n\n\t\tif err != nil {\n\t\t\tpanic(fmt.Errorf("error listing workflows: %w", err))\n\t\t}\n\n\t\tif workflows.JSON200 == nil {\n\t\t\tpanic(fmt.Errorf("no workflows found"))\n\t\t}\n\n\t\trows := *workflows.JSON200.Rows\n\n\t\tif len(rows) == 0 {\n\t\t\tpanic(fmt.Errorf("no workflows found"))\n\t\t}\n\n\t\tworkflowId := uuid.MustParse(rows[0].Metadata.Id)\n\n\t\tworkflowRuns, err := c.API().WorkflowRunListWithResponse(context.Background(), uuid.MustParse(c.TenantId()), &rest.WorkflowRunListParams{\n\t\t\tWorkflowId: &workflowId,\n\t\t})\n\n\t\tif err != nil {\n\t\t\tpanic(fmt.Errorf("error listing workflow runs: %w", err))\n\t\t}\n\n\t\tif workflowRuns.JSON200 == nil {\n\t\t\tpanic(fmt.Errorf("no workflow runs found"))\n\t\t}\n\n\t\tworkflowRunsRows := *workflowRuns.JSON200.Rows\n\n\t\t_, err = c.API().WorkflowRunCancelWithResponse(context.Background(), uuid.MustParse(c.TenantId()), rest.WorkflowRunsCancelRequest{\n\t\t\tWorkflowRunIds: []uuid.UUID{uuid.MustParse(workflowRunsRows[0].Metadata.Id)},\n\t\t})\n\n\t\tif err != nil {\n\t\t\tpanic(fmt.Errorf("error cancelling workflow run: %w", err))\n\t\t}\n\t}()\n\n\tcleanup, err := w.Start()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error starting worker: %w", err)\n\t}\n\n\treturn cleanup, nil\n}\n',
source: 'out/go/z_v0/cancellation/run.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import main from './main';
export { main };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"log"\n\n\t"github.com/joho/godotenv"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/client/compute"\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype userCreateEvent struct {\n\tUsername string `json:"username"`\n\tUserID string `json:"user_id"`\n\tData map[string]string `json:"data"`\n}\n\ntype stepOneOutput struct {\n\tMessage string `json:"message"`\n}\n\nfunc main() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tevents := make(chan string, 50)\n\tinterrupt := cmdutils.InterruptChan()\n\n\tcleanup, err := run(events)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t<-interrupt\n\n\tif err := cleanup(); err != nil {\n\t\tpanic(fmt.Errorf("error cleaning up: %w", err))\n\t}\n}\n\nfunc run(events chan<- string) (func() error, error) {\n\tc, err := client.New()\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error creating client: %w", err)\n\t}\n\n\tw, err := worker.NewWorker(\n\t\tworker.WithClient(\n\t\t\tc,\n\t\t),\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error creating worker: %w", err)\n\t}\n\n\tpool := "test-pool"\n\tbasicCompute := compute.Compute{\n\t\tPool: &pool,\n\t\tNumReplicas: 1,\n\t\tCPUs: 1,\n\t\tMemoryMB: 1024,\n\t\tCPUKind: compute.ComputeKindSharedCPU,\n\t\tRegions: []compute.Region{compute.Region("ewr")},\n\t}\n\n\tperformancePool := "performance-pool"\n\tperformanceCompute := compute.Compute{\n\t\tPool: &performancePool,\n\t\tNumReplicas: 1,\n\t\tCPUs: 2,\n\t\tMemoryMB: 1024,\n\t\tCPUKind: compute.ComputeKindPerformanceCPU,\n\t\tRegions: []compute.Region{compute.Region("ewr")},\n\t}\n\n\terr = w.RegisterWorkflow(\n\t\t&worker.WorkflowJob{\n\t\t\tOn: worker.Events("user:create:simple"),\n\t\t\tName: "simple",\n\t\t\tDescription: "This runs after an update to the user model.",\n\t\t\tConcurrency: worker.Expression("input.user_id"),\n\t\t\tSteps: []*worker.WorkflowStep{\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOneOutput, err error) {\n\t\t\t\t\tinput := &userCreateEvent{}\n\n\t\t\t\t\terr = ctx.WorkflowInput(input)\n\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\n\t\t\t\t\tlog.Printf("step-one")\n\t\t\t\t\tevents <- "step-one"\n\n\t\t\t\t\treturn &stepOneOutput{\n\t\t\t\t\t\tMessage: "Username is: " + input.Username,\n\t\t\t\t\t}, nil\n\t\t\t\t},\n\t\t\t\t).SetName("step-one").SetCompute(&basicCompute),\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOneOutput, err error) {\n\t\t\t\t\tinput := &stepOneOutput{}\n\t\t\t\t\terr = ctx.StepOutput("step-one", input)\n\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\n\t\t\t\t\tlog.Printf("step-two")\n\t\t\t\t\tevents <- "step-two"\n\n\t\t\t\t\treturn &stepOneOutput{\n\t\t\t\t\t\tMessage: "Above message is: " + input.Message,\n\t\t\t\t\t}, nil\n\t\t\t\t}).SetName("step-two").AddParents("step-one").SetCompute(&performanceCompute),\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error registering workflow: %w", err)\n\t}\n\n\tgo func() {\n\t\ttestEvent := userCreateEvent{\n\t\t\tUsername: "echo-test",\n\t\t\tUserID: "1234",\n\t\t\tData: map[string]string{\n\t\t\t\t"test": "test",\n\t\t\t},\n\t\t}\n\n\t\tlog.Printf("pushing event user:create:simple")\n\t\t// push an event\n\t\terr := c.Event().Push(\n\t\t\tcontext.Background(),\n\t\t\t"user:create:simple",\n\t\t\ttestEvent,\n\t\t\tclient.WithEventMetadata(map[string]string{\n\t\t\t\t"hello": "world",\n\t\t\t}),\n\t\t)\n\t\tif err != nil {\n\t\t\tpanic(fmt.Errorf("error pushing event: %w", err))\n\t\t}\n\t}()\n\n\tcleanup, err := w.Start()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn cleanup, nil\n}\n',
source: 'out/go/z_v0/compute/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import main from './main';
export { main };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"fmt"\n\t"log"\n\t"time"\n\n\t"github.com/joho/godotenv"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/client/types"\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype userCreateEvent struct {\n\tUsername string `json:"username"`\n\tUserID string `json:"user_id"`\n\tData map[string]string `json:"data"`\n}\n\ntype stepOneOutput struct {\n\tMessage string `json:"message"`\n}\n\nfunc main() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tevents := make(chan string, 50)\n\tinterrupt := cmdutils.InterruptChan()\n\n\tcleanup, err := run(events)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t<-interrupt\n\n\tif err := cleanup(); err != nil {\n\n\t\tpanic(fmt.Errorf("error cleaning up: %w", err))\n\t}\n}\n\nfunc run(events chan<- string) (func() error, error) {\n\tc, err := client.New()\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error creating client: %w", err)\n\t}\n\n\tw, err := worker.NewWorker(\n\t\tworker.WithClient(\n\t\t\tc,\n\t\t),\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error creating worker: %w", err)\n\t}\n\n\terr = w.RegisterWorkflow(\n\t\t&worker.WorkflowJob{\n\t\t\tOn: worker.Events("user:create:concurrency"),\n\t\t\tName: "simple-concurrency",\n\t\t\tDescription: "This runs to test concurrency.",\n\t\t\tConcurrency: worker.Expression("\'concurrency\'").MaxRuns(1).LimitStrategy(types.GroupRoundRobin),\n\t\t\tSteps: []*worker.WorkflowStep{\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOneOutput, err error) {\n\t\t\t\t\tinput := &userCreateEvent{}\n\n\t\t\t\t\terr = ctx.WorkflowInput(input)\n\n\t\t\t\t\t// we sleep to simulate a long running task\n\t\t\t\t\ttime.Sleep(10 * time.Second)\n\n\t\t\t\t\tif err != nil {\n\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\n\t\t\t\t\tif ctx.Err() != nil {\n\t\t\t\t\t\treturn nil, ctx.Err()\n\t\t\t\t\t}\n\n\t\t\t\t\tlog.Printf("step-one")\n\t\t\t\t\tevents <- "step-one"\n\n\t\t\t\t\treturn &stepOneOutput{\n\t\t\t\t\t\tMessage: "Username is: " + input.Username,\n\t\t\t\t\t}, nil\n\t\t\t\t},\n\t\t\t\t).SetName("step-one"),\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOneOutput, err error) {\n\t\t\t\t\tinput := &stepOneOutput{}\n\t\t\t\t\terr = ctx.StepOutput("step-one", input)\n\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\n\t\t\t\t\tif ctx.Err() != nil {\n\t\t\t\t\t\treturn nil, ctx.Err()\n\t\t\t\t\t}\n\n\t\t\t\t\tlog.Printf("step-two")\n\t\t\t\t\tevents <- "step-two"\n\n\t\t\t\t\treturn &stepOneOutput{\n\t\t\t\t\t\tMessage: "Above message is: " + input.Message,\n\t\t\t\t\t}, nil\n\t\t\t\t}).SetName("step-two").AddParents("step-one"),\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf("error registering workflow: %w", err)\n\t}\n\ttestEvent := userCreateEvent{\n\t\tUsername: "echo-test",\n\t\tUserID: "1234",\n\t\tData: map[string]string{\n\t\t\t"test": "test",\n\t\t},\n\t}\n\tgo func() {\n\t\t// do this 10 times to test concurrency\n\t\tfor i := 0; i < 10; i++ {\n\n\t\t\twfr_id, err := c.Admin().RunWorkflow("simple-concurrency", testEvent)\n\n\t\t\tlog.Println("Starting workflow run id: ", wfr_id)\n\n\t\t\tif err != nil {\n\t\t\t\tpanic(fmt.Errorf("error running workflow: %w", err))\n\t\t\t}\n\n\t\t}\n\t}()\n\n\tcleanup, err := w.Start()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn cleanup, nil\n}\n',
source: 'out/go/z_v0/concurrency/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import main from './main';
export { main };

View File

@@ -0,0 +1,25 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/joho/godotenv"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\n// > Create\n// ... normal workflow definition\ntype printOutput struct{}\n\nfunc print(ctx context.Context) (result *printOutput, err error) {\n\tfmt.Println("called print:print")\n\n\treturn &printOutput{}, nil\n}\n\n// ,\nfunc main() {\n\t// ... initialize client, worker and workflow\n\terr := godotenv.Load()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tc, err := client.New()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tw, err := worker.NewWorker(\n\t\tworker.WithClient(\n\t\t\tc,\n\t\t),\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = w.RegisterWorkflow(\n\t\t&worker.WorkflowJob{\n\t\t\tOn: worker.NoTrigger(),\n\t\t\tName: "cron-workflow",\n\t\t\tDescription: "Demonstrates a simple cron workflow",\n\t\t\tSteps: []*worker.WorkflowStep{\n\t\t\t\tworker.Fn(print),\n\t\t\t},\n\t\t},\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tinterrupt := cmdutils.InterruptChan()\n\n\tcleanup, err := w.Start()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// ,\n\n\tgo func() {\n\t\t// 👀 define the cron expression to run every minute\n\t\tcron, err := c.Cron().Create(\n\t\t\tcontext.Background(),\n\t\t\t"cron-workflow",\n\t\t\t&client.CronOpts{\n\t\t\t\tName: "every-minute",\n\t\t\t\tExpression: "* * * * *",\n\t\t\t\tInput: map[string]interface{}{\n\t\t\t\t\t"message": "Hello, world!",\n\t\t\t\t},\n\t\t\t\tAdditionalMetadata: map[string]string{},\n\t\t\t},\n\t\t)\n\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tfmt.Println(*cron.Name, cron.Cron)\n\t}()\n\n\t// ... wait for interrupt signal\n\n\t<-interrupt\n\n\tif err := cleanup(); err != nil {\n\t\tpanic(fmt.Errorf("error cleaning up: %w", err))\n\t}\n\n\t// ,\n}\n\n\nfunc ListCrons() {\n\n\tc, err := client.New()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// > List\n\tcrons, err := c.Cron().List(context.Background())\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor _, cron := range *crons.Rows {\n\t\tfmt.Println(cron.Cron, *cron.Name)\n\t}\n}\n\nfunc DeleteCron(id string) {\n\tc, err := client.New()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// > Delete\n\t// 👀 id is the cron\'s metadata id, can get it via cron.Metadata.Id\n\terr = c.Cron().Delete(context.Background(), id)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n}\n',
source: 'out/go/z_v0/cron-programmatic/main.go',
blocks: {
create: {
start: 15,
stop: 106,
},
list: {
start: 117,
stop: 117,
},
delete: {
start: 136,
stop: 137,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import main from './main';
export { main };

View File

@@ -0,0 +1,17 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/joho/godotenv"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\n// > Workflow Definition Cron Trigger\n// ... normal workflow definition\ntype printOutput struct{}\n\nfunc print(ctx context.Context) (result *printOutput, err error) {\n\tfmt.Println("called print:print")\n\n\treturn &printOutput{}, nil\n}\n\n// ,\nfunc main() {\n\t// ... initialize client and worker\n\terr := godotenv.Load()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tclient, err := client.New()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tw, err := worker.NewWorker(\n\t\tworker.WithClient(\n\t\t\tclient,\n\t\t),\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// ,\n\terr = w.RegisterWorkflow(\n\t\t&worker.WorkflowJob{\n\t\t\t// 👀 define the cron expression to run every minute\n\t\t\tOn: worker.Cron("* * * * *"),\n\t\t\tName: "cron-workflow",\n\t\t\tDescription: "Demonstrates a simple cron workflow",\n\t\t\tSteps: []*worker.WorkflowStep{\n\t\t\t\tworker.Fn(print),\n\t\t\t},\n\t\t},\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// ... start worker\n\n\tinterrupt := cmdutils.InterruptChan()\n\n\tcleanup, err := w.Start()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t<-interrupt\n\n\tif err := cleanup(); err != nil {\n\t\tpanic(fmt.Errorf("error cleaning up: %w", err))\n\t}\n\n\t// ,\n}\n\n',
source: 'out/go/z_v0/cron/main.go',
blocks: {
workflow_definition_cron_trigger: {
start: 15,
stop: 84,
},
},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import main from './main';
export { main };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"log"\n\t"time"\n\n\t"github.com/joho/godotenv"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype userCreateEvent struct {\n\tUsername string `json:"username"`\n\tUserID string `json:"user_id"`\n\tData map[string]string `json:"data"`\n}\n\ntype stepOutput struct {\n\tMessage string `json:"message"`\n}\n\nfunc main() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tevents := make(chan string, 50)\n\tif err := run(cmdutils.InterruptChan(), events); err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc run(ch <-chan interface{}, events chan<- string) error {\n\tc, err := client.New()\n\n\tif err != nil {\n\t\treturn fmt.Errorf("error creating client: %w", err)\n\t}\n\n\tw, err := worker.NewWorker(\n\t\tworker.WithClient(\n\t\t\tc,\n\t\t),\n\t\tworker.WithMaxRuns(1),\n\t)\n\tif err != nil {\n\t\treturn fmt.Errorf("error creating worker: %w", err)\n\t}\n\n\ttestSvc := w.NewService("test")\n\n\terr = testSvc.On(\n\t\tworker.Events("user:create:simple"),\n\t\t&worker.WorkflowJob{\n\t\t\tName: "post-user-update",\n\t\t\tDescription: "This runs after an update to the user model.",\n\t\t\tSteps: []*worker.WorkflowStep{\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOutput, err error) {\n\t\t\t\t\tinput := &userCreateEvent{}\n\t\t\t\t\tctx.WorkflowInput(input)\n\n\t\t\t\t\ttime.Sleep(1 * time.Second)\n\n\t\t\t\t\treturn &stepOutput{\n\t\t\t\t\t\tMessage: "Step 1 got username: " + input.Username,\n\t\t\t\t\t}, nil\n\t\t\t\t},\n\t\t\t\t).SetName("step-one"),\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOutput, err error) {\n\t\t\t\t\tinput := &userCreateEvent{}\n\t\t\t\t\tctx.WorkflowInput(input)\n\n\t\t\t\t\ttime.Sleep(2 * time.Second)\n\n\t\t\t\t\treturn &stepOutput{\n\t\t\t\t\t\tMessage: "Step 2 got username: " + input.Username,\n\t\t\t\t\t}, nil\n\t\t\t\t}).SetName("step-two"),\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOutput, err error) {\n\t\t\t\t\tinput := &userCreateEvent{}\n\t\t\t\t\tctx.WorkflowInput(input)\n\n\t\t\t\t\tstep1Out := &stepOutput{}\n\t\t\t\t\tctx.StepOutput("step-one", step1Out)\n\n\t\t\t\t\tstep2Out := &stepOutput{}\n\t\t\t\t\tctx.StepOutput("step-two", step2Out)\n\n\t\t\t\t\ttime.Sleep(3 * time.Second)\n\n\t\t\t\t\treturn &stepOutput{\n\t\t\t\t\t\tMessage: "Username was: " + input.Username + ", Step 3: has parents 1 and 2" + step1Out.Message + ", " + step2Out.Message,\n\t\t\t\t\t}, nil\n\t\t\t\t}).SetName("step-three").AddParents("step-one", "step-two"),\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOutput, err error) {\n\t\t\t\t\tstep1Out := &stepOutput{}\n\t\t\t\t\tctx.StepOutput("step-one", step1Out)\n\n\t\t\t\t\tstep3Out := &stepOutput{}\n\t\t\t\t\tctx.StepOutput("step-three", step3Out)\n\n\t\t\t\t\ttime.Sleep(4 * time.Second)\n\n\t\t\t\t\treturn &stepOutput{\n\t\t\t\t\t\tMessage: "Step 4: has parents 1 and 3" + step1Out.Message + ", " + step3Out.Message,\n\t\t\t\t\t}, nil\n\t\t\t\t}).SetName("step-four").AddParents("step-one", "step-three"),\n\t\t\t\tworker.Fn(func(ctx worker.HatchetContext) (result *stepOutput, err error) {\n\t\t\t\t\tstep4Out := &stepOutput{}\n\t\t\t\t\tctx.StepOutput("step-four", step4Out)\n\n\t\t\t\t\ttime.Sleep(5 * time.Second)\n\n\t\t\t\t\treturn &stepOutput{\n\t\t\t\t\t\tMessage: "Step 5: has parent 4" + step4Out.Message,\n\t\t\t\t\t}, nil\n\t\t\t\t}).SetName("step-five").AddParents("step-four"),\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn fmt.Errorf("error registering workflow: %w", err)\n\t}\n\n\tinterruptCtx, cancel := cmdutils.InterruptContextFromChan(ch)\n\tdefer cancel()\n\n\tcleanup, err := w.Start()\n\tif err != nil {\n\t\treturn fmt.Errorf("error starting worker: %w", err)\n\t}\n\n\ttestEvent := userCreateEvent{\n\t\tUsername: "echo-test",\n\t\tUserID: "1234",\n\t\tData: map[string]string{\n\t\t\t"test": "test",\n\t\t},\n\t}\n\n\tlog.Printf("pushing event user:create:simple")\n\n\t// push an event\n\terr = c.Event().Push(\n\t\tcontext.Background(),\n\t\t"user:create:simple",\n\t\ttestEvent,\n\t)\n\n\tif err != nil {\n\t\treturn fmt.Errorf("error pushing event: %w", err)\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase <-interruptCtx.Done():\n\t\t\treturn cleanup()\n\t\tdefault:\n\t\t\ttime.Sleep(time.Second)\n\t\t}\n\t}\n}\n',
source: 'out/go/z_v0/dag/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,9 @@
import * as requeue from './requeue';
import * as schedule_timeout from './schedule-timeout';
import * as timeout from './timeout';
import * as yaml from './yaml';
export { requeue };
export { schedule_timeout };
export { timeout };
export { yaml };

View File

@@ -0,0 +1,3 @@
import job_requeue_workflow from './job-requeue-workflow';
export { job_requeue_workflow };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'unknown',
content:
'name: "test-step-requeue"\nversion: v0.2.0\ntriggers:\n events:\n - example:event\njobs:\n requeue-job:\n steps:\n - id: requeue\n action: requeue:requeue\n timeout: 10s\n',
source: 'out/go/z_v0/deprecated/requeue/.hatchet/job-requeue-workflow.yaml',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,5 @@
import main from './main';
import * as hatchet from './.hatchet';
export { main };
export { hatchet };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/joho/godotenv"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype sampleEvent struct{}\n\ntype requeueInput struct{}\n\nfunc main() {\n\terr := godotenv.Load()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tclient, err := client.New(\n\t\tclient.InitWorkflows(),\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tworker, err := worker.NewWorker(\n\t\tworker.WithClient(\n\t\t\tclient,\n\t\t),\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = worker.RegisterAction("requeue:requeue", func(ctx context.Context, input *requeueInput) (result any, err error) {\n\t\treturn map[string]interface{}{}, nil\n\t})\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tinterruptCtx, cancel := cmdutils.InterruptContextFromChan(cmdutils.InterruptChan())\n\tdefer cancel()\n\n\tevent := sampleEvent{}\n\n\t// push an event\n\terr = client.Event().Push(\n\t\tcontext.Background(),\n\t\t"example:event",\n\t\tevent,\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// wait to register the worker for 10 seconds, to let the requeuer kick in\n\ttime.Sleep(10 * time.Second)\n\tcleanup, err := worker.Start()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase <-interruptCtx.Done():\n\t\t\tif err := cleanup(); err != nil {\n\t\t\t\tpanic(fmt.Errorf("error cleaning up: %w", err))\n\t\t\t}\n\t\t\treturn\n\t\tdefault:\n\t\t\ttime.Sleep(time.Second)\n\t\t}\n\t}\n}\n',
source: 'out/go/z_v0/deprecated/requeue/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import schedule_timeout_workflow from './schedule-timeout-workflow';
export { schedule_timeout_workflow };

View File

@@ -0,0 +1,13 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'unknown',
content:
'name: "test-schedule-timeout"\nversion: v0.1.0\ntriggers:\n events:\n - user:create\njobs:\n timeout-job:\n steps:\n - id: timeout\n action: timeout:timeout\n',
source:
'out/go/z_v0/deprecated/schedule-timeout/.hatchet/schedule-timeout-workflow.yaml',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,5 @@
import main from './main';
import * as hatchet from './.hatchet';
export { main };
export { hatchet };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/joho/godotenv"\n)\n\ntype sampleEvent struct{}\n\ntype timeoutInput struct{}\n\nfunc main() {\n\terr := godotenv.Load()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tclient, err := client.New(\n\t\tclient.InitWorkflows(),\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tevent := sampleEvent{}\n\n\t// push an event\n\terr = client.Event().Push(\n\t\tcontext.Background(),\n\t\t"user:create",\n\t\tevent,\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\ttime.Sleep(35 * time.Second)\n\n\tfmt.Println("step should have timed out")\n}\n',
source: 'out/go/z_v0/deprecated/schedule-timeout/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,5 @@
import job_timeout_workflow from './job-timeout-workflow';
import step_timeout_workflow from './step-timeout-workflow';
export { job_timeout_workflow };
export { step_timeout_workflow };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'unknown',
content:
'name: "test-job-timeout"\nversion: v0.1.0\ntriggers:\n events:\n - user:create\njobs:\n timeout-job:\n timeout: 3s\n steps:\n - id: timeout\n action: timeout:timeout\n timeout: 10s\n',
source: 'out/go/z_v0/deprecated/timeout/.hatchet/job-timeout-workflow.yaml',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'unknown',
content:
'name: "test-step-timeout"\nversion: v0.1.0\ntriggers:\n events:\n - user:create\njobs:\n timeout-job:\n steps:\n - id: timeout\n action: timeout:timeout\n timeout: 5s\n # This step should not be reached\n - id: later-step\n action: timeout:timeout\n timeout: 5s\n',
source: 'out/go/z_v0/deprecated/timeout/.hatchet/step-timeout-workflow.yaml',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,5 @@
import main from './main';
import * as hatchet from './.hatchet';
export { main };
export { hatchet };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/joho/godotenv"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype sampleEvent struct{}\n\ntype timeoutInput struct{}\n\nfunc main() {\n\terr := godotenv.Load()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tclient, err := client.New(\n\t\tclient.InitWorkflows(),\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tworker, err := worker.NewWorker(\n\t\tworker.WithClient(\n\t\t\tclient,\n\t\t),\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = worker.RegisterAction("timeout:timeout", func(ctx context.Context, input *timeoutInput) (result any, err error) {\n\t\t// wait for context done signal\n\t\ttimeStart := time.Now().UTC()\n\t\t<-ctx.Done()\n\t\tfmt.Println("context cancelled in ", time.Since(timeStart).Seconds(), " seconds")\n\n\t\treturn map[string]interface{}{}, nil\n\t})\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tinterruptCtx, cancel := cmdutils.InterruptContextFromChan(cmdutils.InterruptChan())\n\tdefer cancel()\n\n\tcleanup, err := worker.Start()\n\tif err != nil {\n\t\tpanic(fmt.Errorf("error starting worker: %w", err))\n\t}\n\n\tevent := sampleEvent{}\n\n\t// push an event\n\terr = client.Event().Push(\n\t\tcontext.Background(),\n\t\t"user:create",\n\t\tevent,\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase <-interruptCtx.Done():\n\t\t\tif err := cleanup(); err != nil {\n\t\t\t\tpanic(fmt.Errorf("error cleaning up: %w", err))\n\t\t\t}\n\t\t\treturn\n\t\tdefault:\n\t\t\ttime.Sleep(time.Second)\n\t\t}\n\t}\n}\n',
source: 'out/go/z_v0/deprecated/timeout/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import sample_workflow from './sample-workflow';
export { sample_workflow };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'unknown',
content:
'name: "post-user-sign-up"\nversion: v0.2.0\ntriggers:\n events:\n - user:create\njobs:\n print-user:\n steps:\n - id: echo1\n action: echo:echo\n timeout: 60s\n with:\n message: "Username is {{ .input.username }}"\n - id: echo2\n action: echo:echo\n timeout: 60s\n with:\n message: "Above message is: {{ .steps.echo1.message }}"\n - id: echo3\n action: echo:echo\n timeout: 60s\n with:\n message: "Above message is: {{ .steps.echo2.message }}"\n - id: testObject\n action: echo:object\n timeout: 60s\n with:\n object: "{{ .steps.echo3.json }}"\n',
source: 'out/go/z_v0/deprecated/yaml/.hatchet/sample-workflow.yaml',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'unknown',
content:
"## YAML Workflow Example\n\nThis example shows how you can create a YAML file in your repository to define the structure of a workflow. This example runs the [sample-workflow.yaml](./.hatchet/sample-workflow.yaml).\n\n## Explanation\n\nThis folder contains a demo example of a workflow that simply echoes the input message as an output. The workflow file showcases the following features:\n\n- Running a simple job with a set of dependent steps\n- Variable references within step arguments -- each subsequent step in a workflow can call `.steps.<step_id>.<field>` to access output arguments\n\n## How to run\n\nNavigate to this directory and run the following steps:\n\n1. Make sure you have a Hatchet server running (see the instructions [here](../../README.md)). After running `task seed`, grab the tenant ID which is output to the console.\n2. Set your environment variables -- if you're using the bundled Temporal server, this will look like:\n\n```sh\ncat > .env <<EOF\nHATCHET_CLIENT_TENANT_ID=<tenant-id-from-seed-command>\nHATCHET_CLIENT_TLS_ROOT_CA_FILE=../../hack/dev/certs/ca.cert\nHATCHET_CLIENT_TLS_CERT_FILE=../../hack/dev/certs/client-worker.pem\nHATCHET_CLIENT_TLS_KEY_FILE=../../hack/dev/certs/client-worker.key\nHATCHET_CLIENT_TLS_SERVER_NAME=cluster\nEOF\n```\n\n3. Run the following within this directory:\n\n```sh\ngo run main.go';\n```\n",
source: 'out/go/z_v0/deprecated/yaml/README.md',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,7 @@
import readme from './README';
import main from './main';
import * as hatchet from './.hatchet';
export { readme };
export { main };
export { hatchet };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/joho/godotenv"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype userCreateEvent struct {\n\tUsername string `json:"username"`\n\tUserId string `json:"user_id"`\n\tData map[string]string `json:"data"`\n}\n\ntype actionInput struct {\n\tMessage string `json:"message"`\n}\n\ntype actionOut struct {\n\tMessage string `json:"message"`\n}\n\nfunc echo(ctx context.Context, input *actionInput) (result *actionOut, err error) {\n\treturn &actionOut{\n\t\tMessage: input.Message,\n\t}, nil\n}\n\nfunc object(ctx context.Context, input *userCreateEvent) error {\n\treturn nil\n}\n\nfunc main() {\n\terr := godotenv.Load()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tclient, err := client.New(\n\t\tclient.InitWorkflows(),\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tworker, err := worker.NewWorker(\n\t\tworker.WithClient(\n\t\t\tclient,\n\t\t),\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\techoSvc := worker.NewService("echo")\n\n\terr = echoSvc.RegisterAction(echo)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = echoSvc.RegisterAction(object)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tch := cmdutils.InterruptChan()\n\n\tcleanup, err := worker.Start()\n\tif err != nil {\n\t\tpanic(fmt.Errorf("error starting worker: %w", err))\n\t}\n\n\ttestEvent := userCreateEvent{\n\t\tUsername: "echo-test",\n\t\tUserId: "1234",\n\t\tData: map[string]string{\n\t\t\t"test": "test",\n\t\t},\n\t}\n\n\ttime.Sleep(1 * time.Second)\n\n\t// push an event\n\terr = client.Event().Push(\n\t\tcontext.Background(),\n\t\t"user:create",\n\t\ttestEvent,\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t<-ch\n\n\tif err := cleanup(); err != nil {\n\t\tpanic(fmt.Errorf("error cleaning up worker: %w", err))\n\t}\n}\n',
source: 'out/go/z_v0/deprecated/yaml/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,3 @@
import main from './main';
export { main };

View File

@@ -0,0 +1,12 @@
import { Snippet } from '@/next/lib/docs/generated/snips/types';
const snippet: Snippet = {
language: 'go',
content:
'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"os"\n\n\t"github.com/joho/godotenv"\n\n\t"github.com/hatchet-dev/hatchet/pkg/client"\n\t"github.com/hatchet-dev/hatchet/pkg/cmdutils"\n\t"github.com/hatchet-dev/hatchet/pkg/errors/sentry"\n\t"github.com/hatchet-dev/hatchet/pkg/worker"\n)\n\ntype userCreateEvent struct {\n\tUsername string `json:"username"`\n\tUserId string `json:"user_id"`\n\tData map[string]string `json:"data"`\n}\n\ntype stepOneOutput struct {\n\tMessage string `json:"message"`\n}\n\nfunc StepOne(ctx context.Context) (result *stepOneOutput, err error) {\n\treturn nil, fmt.Errorf("this is an error")\n}\n\nfunc main() {\n\terr := godotenv.Load()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tclient, err := client.New()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tsentryAlerter, err := sentry.NewSentryAlerter(&sentry.SentryAlerterOpts{\n\t\tDSN: os.Getenv("SENTRY_DSN"),\n\t\tEnvironment: os.Getenv("SENTRY_ENVIRONMENT"),\n\t})\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tw, err := worker.NewWorker(\n\t\tworker.WithClient(\n\t\t\tclient,\n\t\t),\n\t\tworker.WithErrorAlerter(sentryAlerter),\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = w.On(worker.Event("user:create"), &worker.WorkflowJob{\n\t\tName: "failing-workflow",\n\t\tDescription: "This is a failing workflow.",\n\t\tSteps: []*worker.WorkflowStep{\n\t\t\t{\n\t\t\t\tFunction: StepOne,\n\t\t\t},\n\t\t},\n\t})\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// err = worker.RegisterAction("echo:echo", func(ctx context.Context, input *actionInput) (result any, err error) {\n\t// \treturn map[string]interface{}{\n\t// \t\t"message": input.Message,\n\t// \t}, nil\n\t// })\n\n\t// if err != nil {\n\t// \tpanic(err)\n\t// }\n\n\t// err = worker.RegisterAction("echo:object", func(ctx context.Context, input *actionInput) (result any, err error) {\n\t// \treturn nil, nil\n\t// })\n\n\t// if err != nil {\n\t// \tpanic(err)\n\t// }\n\n\tch := cmdutils.InterruptChan()\n\n\tcleanup, err := w.Start()\n\tif err != nil {\n\t\tpanic(fmt.Errorf("error starting worker: %w", err))\n\t}\n\n\ttestEvent := userCreateEvent{\n\t\tUsername: "echo-test",\n\t\tUserId: "1234",\n\t\tData: map[string]string{\n\t\t\t"test": "test",\n\t\t},\n\t}\n\n\t// push an event\n\terr = client.Event().Push(\n\t\tcontext.Background(),\n\t\t"user:create",\n\t\ttestEvent,\n\t)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t<-ch\n\n\tif err := cleanup(); err != nil {\n\t\tpanic(fmt.Errorf("error cleaning up: %w", err))\n\t}\n}\n',
source: 'out/go/z_v0/errors-test/main.go',
blocks: {},
highlights: {},
};
export default snippet;

View File

@@ -0,0 +1,61 @@
import * as assignment_affinity from './assignment-affinity';
import * as assignment_sticky from './assignment-sticky';
import * as bulk_imports from './bulk_imports';
import * as bulk_workflows from './bulk_workflows';
import * as cancellation from './cancellation';
import * as compute from './compute';
import * as concurrency from './concurrency';
import * as cron from './cron';
import * as cron_programmatic from './cron-programmatic';
import * as dag from './dag';
import * as deprecated from './deprecated';
import * as errors_test from './errors-test';
import * as limit_concurrency from './limit-concurrency';
import * as logging from './logging';
import * as manual_trigger from './manual-trigger';
import * as middleware from './middleware';
import * as namespaced from './namespaced';
import * as no_tls from './no-tls';
import * as on_failure from './on-failure';
import * as procedural from './procedural';
import * as rate_limit from './rate-limit';
import * as register_action from './register-action';
import * as retries from './retries';
import * as retries_with_backoff from './retries-with-backoff';
import * as scheduled from './scheduled';
import * as simple from './simple';
import * as stream_event from './stream-event';
import * as stream_event_by_meta from './stream-event-by-meta';
import * as timeout from './timeout';
import * as webhook from './webhook';
export { assignment_affinity };
export { assignment_sticky };
export { bulk_imports };
export { bulk_workflows };
export { cancellation };
export { compute };
export { concurrency };
export { cron };
export { cron_programmatic };
export { dag };
export { deprecated };
export { errors_test };
export { limit_concurrency };
export { logging };
export { manual_trigger };
export { middleware };
export { namespaced };
export { no_tls };
export { on_failure };
export { procedural };
export { rate_limit };
export { register_action };
export { retries };
export { retries_with_backoff };
export { scheduled };
export { simple };
export { stream_event };
export { stream_event_by_meta };
export { timeout };
export { webhook };

Some files were not shown because too many files have changed in this diff Show More