Skip to content

Instantly share code, notes, and snippets.

@ifuller1
Last active July 30, 2024 10:19
Show Gist options
  • Save ifuller1/4c9cc95ee24d610e91067cadb3045e19 to your computer and use it in GitHub Desktop.
Save ifuller1/4c9cc95ee24d610e91067cadb3045e19 to your computer and use it in GitHub Desktop.
Investa Workflow Example
[
{
"equity-pricing": {
"steps": [
{
"check-out-of-hours": {
"steps": [
{
"get-current-time": {
"assign": [
{
"currentHour": "${text.substring(time.format(sys.now()), 11, 13)}"
}
]
}
},
{
"parse_hour": {
"assign": [
{
"hour": "${int(currentHour)}"
}
]
}
},
{
"switch-on-time": {
"switch": [
{
"condition": "${hour >= 23}",
"next": "end"
}
]
}
}
]
}
},
{
"check-existing-executions": {
"steps": [
{
"call-executions-endpoint": {
"call": "http.get",
"args": {
"url": "https://workflowexecutions.googleapis.com/v1/projects/<project_id>/locations/<location>/workflows/<workflow_name>/executions?filter=state%3D%22ACTIVE%22",
"auth": {
"type": "OAuth2"
}
},
"result": "executions"
}
},
{
"switch-on-execution-response": {
"switch": [
{
"condition": "${len(executions.body.executions) > 1}",
"next": "end"
},
{
"condition": "${len(executions.body.executions) <= 1}",
"next": "call-equity-pricing-update"
}
]
}
}
]
}
},
{
"loop-pricing-update": {
"steps": [
{
"call-equity-pricing-update": {
"try": {
"call": "http.get",
"args": {
"url": "https://<function_url>",
"auth": {
"type": "OIDC"
}
},
"result": "equityPricingResult"
},
"retry": {
"predicate": "${http.default_retry_predicate}",
"max_retries": 5,
"backoff": {
"initial_delay": 5,
"max_delay": 30,
"multiplier": 2
}
}
}
},
{
"wait-seconds": {
"call": "sys.sleep",
"args": {
"seconds": 10
},
"next": "call-equity-pricing-update"
}
}
]
}
}
]
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment