-
Run Temporal server on Terminal 1
temporal server start-dev
-
Run temporal workflows implemented in this project on Terminal 2
go test -v ./workflows --run Test_Workflow1
Note:- For temporal installation check https://docs.temporal.io/kb/all-the-ways-to-run-a-cluster
go test -v ./workflows --run Test1
-
workflows/mock_api_server.go
: Implements a mock API server having the following end points- live_hooks
- media_stream_to_abr_converter
-
workflows/workflow.go
: Implements a temporal workflow calledCasWorkflow
.CasWorkflow
creates a DAG of activities and executes them. Each activity is essentially a POST call to mock server to create resource instances. Also implementsCleanupActivity
which is executed when workflow is cancelled or times out to cleanup all resources created by the workflow. -
workflows/testdata/eg_workflow.yaml: A sample declaration of workflow. The dependency of
media_stream_to_abr_converter
onlive_hooks
is declared here asvalue_expressions
in the yaml file. Thevalues_expressions
are somewhat similar to go template variables. The values of these variables are evaluated at runtime by the workflow. -
workflows/workflow_test.go
: Implements test cases running workflows. A temporal worker is a goroutine waiting on queue to process workflow tasks. The test cases start a temporal worker and then start a workflow. The test cases then wait for workflow to complete.