From 5c63363f323466a99c1175cc37c74775be2ad335 Mon Sep 17 00:00:00 2001 From: Quinn Klassen Date: Mon, 11 Mar 2024 16:18:14 -0700 Subject: [PATCH] Add typed search attribute sample and Update Go SDK to v1.26.0 (#331) * Add typed search attribute sample * Update to Go SDK v1.26.0 --- README.md | 5 +- go.mod | 32 +++-- go.sum | 64 +++++----- recovery/recovery_workflow.go | 7 +- schedule/workflow.go | 3 +- searchattributes/README.md | 2 + searchattributes/searchattributes_workflow.go | 5 + temporal-fixtures/namespaces/main.go | 3 +- typed-searchattributes/README.md | 14 +++ .../searchattributes_workflow.go | 109 ++++++++++++++++++ .../searchattributes_workflow_test.go | 38 ++++++ typed-searchattributes/starter/main.go | 35 ++++++ typed-searchattributes/worker/main.go | 30 +++++ 13 files changed, 290 insertions(+), 57 deletions(-) create mode 100644 typed-searchattributes/README.md create mode 100644 typed-searchattributes/searchattributes_workflow.go create mode 100644 typed-searchattributes/searchattributes_workflow_test.go create mode 100644 typed-searchattributes/starter/main.go create mode 100644 typed-searchattributes/worker/main.go diff --git a/README.md b/README.md index 76a5ad96..6899607b 100644 --- a/README.md +++ b/README.md @@ -106,9 +106,8 @@ Each sample demonstrates one feature of the SDK, together with tests. - [**Memo**](./memo): Demonstrates how to use Memo that can be used to store any kind of data. -- [**Search Attributes**](./searchattributes): Demonstrates how to - use custom Search Attributes that can be used to find Workflow Executions using predicates (must use - with [Elasticsearch](https://docs.temporal.io/cluster-deployment-guide/#elasticsearch)). +- [**Typed Search Attributes**](./typed-searchattributes): Demonstrates how to + use custom Search Attributes that can be used to find Workflow Executions using predicates/ - [**Timer Futures**](./timer): The sample starts a long running order processing operation and starts a Timer (`workflow.NewTimer()`). If the processing time is too long, a diff --git a/go.mod b/go.mod index dd2aebd7..5ecf0dd2 100644 --- a/go.mod +++ b/go.mod @@ -7,12 +7,12 @@ replace github.com/cactus/go-statsd-client => github.com/cactus/go-statsd-client require ( github.com/golang/mock v1.7.0-rc.1 github.com/golang/snappy v0.0.4 - github.com/google/uuid v1.4.0 + github.com/google/uuid v1.6.0 github.com/hashicorp/go-plugin v1.4.5 github.com/opentracing/opentracing-go v1.2.0 github.com/pborman/uuid v1.2.1 github.com/prometheus/client_golang v1.18.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/temporalio/tctl v1.18.0 github.com/uber-go/tally/v4 v4.1.7 github.com/uber/jaeger-client-go v2.30.0+incompatible @@ -20,14 +20,15 @@ require ( go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.16.0 go.opentelemetry.io/otel/sdk v1.22.0 go.opentelemetry.io/otel/trace v1.22.0 - go.temporal.io/api v1.26.0 - go.temporal.io/sdk v1.25.1 + go.temporal.io/api v1.29.1 + go.temporal.io/sdk v1.26.0 go.temporal.io/sdk/contrib/opentelemetry v0.3.0 go.temporal.io/sdk/contrib/opentracing v0.1.0 go.temporal.io/sdk/contrib/tally v0.2.0 go.temporal.io/sdk/contrib/tools/workflowcheck v0.0.0-20230612164027-11c2cb9e7d2d go.uber.org/multierr v1.11.0 go.uber.org/zap v1.24.0 + google.golang.org/protobuf v1.33.0 gopkg.in/square/go-jose.v2 v2.6.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -42,12 +43,10 @@ require ( github.com/fatih/color v1.15.0 // indirect github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/gogo/status v1.1.1 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect - github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect github.com/hashicorp/go-hclog v1.3.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/mattn/go-colorable v0.1.13 // indirect @@ -61,21 +60,20 @@ require ( github.com/prometheus/common v0.45.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/robfig/cron v1.2.0 // indirect - github.com/stretchr/objx v0.5.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/twmb/murmur3 v1.1.8 // indirect github.com/uber/jaeger-lib v2.4.1+incompatible // indirect go.opentelemetry.io/otel/metric v1.22.0 // indirect go.uber.org/atomic v1.11.0 // indirect - golang.org/x/crypto v0.16.0 // indirect - golang.org/x/net v0.19.0 // indirect - golang.org/x/sys v0.16.0 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect + golang.org/x/net v0.22.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.16.0 // indirect - google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/grpc v1.60.1 // indirect - google.golang.org/protobuf v1.32.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 // indirect + google.golang.org/grpc v1.62.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 3f136656..722c7f54 100644 --- a/go.sum +++ b/go.sum @@ -62,15 +62,12 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= -github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= -github.com/gogo/status v1.1.1 h1:DuHXlSFHNKqTQ+/ACf5Vs6r4X/dH2EgIzR9Vr+H65kg= -github.com/gogo/status v1.1.1/go.mod h1:jpG3dM5QPcqu19Hg8lkUhBFBa3TcLs1DG7+2Jqci7oU= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -91,8 +88,8 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -109,13 +106,14 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= -github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= github.com/hashicorp/go-hclog v1.3.1 h1:vDwF1DFNZhntP4DAjuTpOw3uEgMUpXh1pB5fW9DqHpo= github.com/hashicorp/go-hclog v1.3.1/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-plugin v1.4.5 h1:oTE/oQR4eghggRg8VY7PAz3dr++VwDNBGCcOfIvHpBo= @@ -204,8 +202,8 @@ github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3c github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ= github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= @@ -214,8 +212,9 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -224,8 +223,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/temporalio/tctl v1.18.0 h1:f4kar5U66kPWKcHX767QHBzfhAXVbxdeWREeNvPxFTQ= github.com/temporalio/tctl v1.18.0/go.mod h1:xhPOWigAcef9+Ci11hZHgxCsfcjXKO7Upt6V6snuCWc= github.com/twmb/murmur3 v1.1.5/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ= @@ -258,11 +258,11 @@ go.opentelemetry.io/otel/trace v1.22.0 h1:Hg6pPujv0XG9QaVbGOBVHunyuLcCC3jN7WEhPx go.opentelemetry.io/otel/trace v1.22.0/go.mod h1:RbbHXVqKES9QhzZq/fE5UnOSILqRt40a21sPw2He1xo= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.temporal.io/api v1.5.0/go.mod h1:BqKxEJJYdxb5dqf0ODfzfMxh8UEQ5L3zKS51FiIYYkA= -go.temporal.io/api v1.26.0 h1:N4V0Daqa0qqK5+9LELSZV7clBYrwB4l33iaFfKgycPk= -go.temporal.io/api v1.26.0/go.mod h1:uVAcpQJ6bM4mxZ3m7vSHU65fHjrwy9ktGQMtsNfMZQQ= +go.temporal.io/api v1.29.1 h1:L722DCy3xCzpTe3Rvh1sFC9kcSaMJXqvodCF+swHGtQ= +go.temporal.io/api v1.29.1/go.mod h1:wZtsUJ3PySASGWbpXBWYVKJ4aHB2ZODEn/xNcTr9HRs= go.temporal.io/sdk v1.12.0/go.mod h1:lSp3lH1lI0TyOsus0arnO3FYvjVXBZGi/G7DjnAnm6o= -go.temporal.io/sdk v1.25.1 h1:jC9l9vHHz5OJ7PR6OjrpYSN4+uEG0bLe5rdF9nlMSGk= -go.temporal.io/sdk v1.25.1/go.mod h1:X7iFKZpsj90BfszfpFCzLX8lwEJXbnRrl351/HyEgmU= +go.temporal.io/sdk v1.26.0 h1:QAi7irgKvJI+5cKmvy+1lkdCDJJDDNpIQAoXdr3dcyM= +go.temporal.io/sdk v1.26.0/go.mod h1:rcAf1YWlbWgMsjJEuz7XiQd6UYxTQDOk2AqRRIDwq/U= go.temporal.io/sdk/contrib/opentelemetry v0.3.0 h1:wOEErZugJF1NcBpcxEAmOQmrcRBw3Plx5+LacEbZ1CE= go.temporal.io/sdk/contrib/opentelemetry v0.3.0/go.mod h1:V0kUHBikUWh3fb4WufUKXd8tKrFO3isZM+MmrfJKIGM= go.temporal.io/sdk/contrib/opentracing v0.1.0 h1:z5F1EoZQ6v8bMH/pzcFRgzoPKZCB+exUKMYt0jzuWME= @@ -293,14 +293,16 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20231127185646-65229373498e h1:Gvh4YaCaXNs6dKTlfgismwWZKyjVZXwOPfIyUaqU3No= +golang.org/x/exp v0.0.0-20231127185646-65229373498e/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -337,8 +339,8 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20210913180222-943fd674d43e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -385,8 +387,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -436,12 +438,10 @@ google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 h1:nz5NESFLZbJGPFxDT/HCn+V1mZ8JGNoY4nUpmW/Y2eg= -google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917/go.mod h1:pZqR+glSb11aJ+JQcczCvgf47+duRuzNSKqE8YAQnV0= -google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 h1:rcS6EyEaoCO52hQDupoSfrxI3R6C2Tq741is7X8OvnM= -google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917/go.mod h1:CmlNWB9lSezaYELKS5Ym1r44VrrbPUa7JTvw+6MbpJ0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 h1:6G8oQ016D88m1xAKljMlBOOGWDZkes4kMhgGFlf8WcQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917/go.mod h1:xtjpI3tXFPP051KaWnhvxkiubL/6dJ18vLVf7q2pTOU= +google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8 h1:8eadJkXbwDEMNwcB5O0s5Y5eCfyuCLdvaiOIaGTrWmQ= +google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8/go.mod h1:O1cOfN1Cy6QEYr7VxtjOyP5AdAuR0aJ/MYZaaof623Y= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 h1:IR+hp6ypxjH24bkMfEJ0yHR21+gwPWdV+/IBrPQyn3k= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8/go.mod h1:UCOku4NytXMJuLQE5VuqA5lX3PcHCBo8pxNyvkf4xBs= google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= @@ -451,8 +451,8 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= -google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= +google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= +google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -465,8 +465,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/recovery/recovery_workflow.go b/recovery/recovery_workflow.go index d01ca30e..51f4551a 100644 --- a/recovery/recovery_workflow.go +++ b/recovery/recovery_workflow.go @@ -15,6 +15,7 @@ import ( "go.temporal.io/sdk/client" "go.temporal.io/sdk/temporal" "go.temporal.io/sdk/workflow" + "google.golang.org/protobuf/types/known/timestamppb" "github.com/temporalio/samples-go/recovery/cache" ) @@ -288,7 +289,7 @@ func extractStateFromEvent(workflowID string, event *historypb.HistoryEvent) (*R Options: client.StartWorkflowOptions{ ID: workflowID, TaskQueue: attr.TaskQueue.GetName(), - WorkflowTaskTimeout: *attr.GetWorkflowTaskTimeout(), + WorkflowTaskTimeout: attr.GetWorkflowTaskTimeout().AsDuration(), // RetryPolicy: attr.RetryPolicy, }, State: state, @@ -344,8 +345,8 @@ func getAllExecutionsOfType(ctx context.Context, c client.Client, workflowType s MaximumPageSize: 10, NextPageToken: nextPageToken, StartTimeFilter: &filterpb.StartTimeFilter{ - EarliestTime: &zeroTime, - LatestTime: &now, + EarliestTime: timestamppb.New(zeroTime), + LatestTime: timestamppb.New(now), }, Filters: &workflowservice.ListOpenWorkflowExecutionsRequest_TypeFilter{TypeFilter: &filterpb.WorkflowTypeFilter{ Name: workflowType, diff --git a/schedule/workflow.go b/schedule/workflow.go index 35198317..889bd987 100644 --- a/schedule/workflow.go +++ b/schedule/workflow.go @@ -23,13 +23,14 @@ func SampleScheduleWorkflow(ctx workflow.Context) error { info := workflow.GetInfo(ctx1) // Workflow Executions started by a Schedule have the following additional properties appended to their search attributes + //lint:ignore SA1019 - this is a sample scheduledByIDPayload := info.SearchAttributes.IndexedFields["TemporalScheduledById"] var scheduledByID string err := converter.GetDefaultDataConverter().FromPayload(scheduledByIDPayload, &scheduledByID) if err != nil { return err } - + //lint:ignore SA1019 - this is a sample startTimePayload := info.SearchAttributes.IndexedFields["TemporalScheduledStartTime"] var startTime time.Time err = converter.GetDefaultDataConverter().FromPayload(startTimePayload, &startTime) diff --git a/searchattributes/README.md b/searchattributes/README.md index 05d64b6b..7021995b 100644 --- a/searchattributes/README.md +++ b/searchattributes/README.md @@ -1,3 +1,5 @@ +This sample is now out of data, please see the ./typed-searchattributes sample. + ### Steps to run this sample: 1) Run [Temporal Server](Run a [Temporal service](https://github.com/temporalio/samples-go/tree/main/#how-to-use) with an Advanced Visibility store (Elasticsearch integrated). If you are using the default `docker-compose` config, then Elasticsearch is already integrated. diff --git a/searchattributes/searchattributes_workflow.go b/searchattributes/searchattributes_workflow.go index 6c939d86..b210e4cc 100644 --- a/searchattributes/searchattributes_workflow.go +++ b/searchattributes/searchattributes_workflow.go @@ -43,6 +43,7 @@ func SearchAttributesWorkflow(ctx workflow.Context) error { // Get search attributes that were provided when workflow was started. info := workflow.GetInfo(ctx) + //lint:ignore SA1019 - this is a sample val := info.SearchAttributes.IndexedFields["CustomIntField"] var currentIntValue int err := converter.GetDefaultDataConverter().FromPayload(val, ¤tIntValue) @@ -63,6 +64,7 @@ func SearchAttributesWorkflow(ctx workflow.Context) error { } // This won't persist search attributes on server because commands are not sent to server, // but local cache will be updated. + //lint:ignore SA1019 - this is a sample err = workflow.UpsertSearchAttributes(ctx, attributes) if err != nil { return err @@ -70,6 +72,7 @@ func SearchAttributesWorkflow(ctx workflow.Context) error { // Print current search attributes with modifications above. info = workflow.GetInfo(ctx) + //lint:ignore SA1019 - this is a sample err = printSearchAttributes(info.SearchAttributes, logger) if err != nil { return err @@ -79,6 +82,7 @@ func SearchAttributesWorkflow(ctx workflow.Context) error { attributes = map[string]interface{}{ "CustomKeywordField": "Update2", } + //lint:ignore SA1019 - this is a sample err = workflow.UpsertSearchAttributes(ctx, attributes) if err != nil { return err @@ -86,6 +90,7 @@ func SearchAttributesWorkflow(ctx workflow.Context) error { // Print current search attributes. info = workflow.GetInfo(ctx) + //lint:ignore SA1019 - this is a sample err = printSearchAttributes(info.SearchAttributes, logger) if err != nil { return err diff --git a/temporal-fixtures/namespaces/main.go b/temporal-fixtures/namespaces/main.go index 892b3aed..e0c4faa9 100644 --- a/temporal-fixtures/namespaces/main.go +++ b/temporal-fixtures/namespaces/main.go @@ -8,6 +8,7 @@ import ( "log" "github.com/pborman/uuid" + "google.golang.org/protobuf/types/known/durationpb" "strconv" @@ -35,7 +36,7 @@ func main() { Namespace: uuidvar + "_" + strconv.Itoa(i), Description: "Namespace Description " + strconv.Itoa(i), OwnerEmail: "owner@mail.com", - WorkflowExecutionRetentionPeriod: &retention, + WorkflowExecutionRetentionPeriod: durationpb.New(retention), } if err = c.Register(context.Background(), req); err != nil { log.Fatalln("Unable to register namespace", err) diff --git a/typed-searchattributes/README.md b/typed-searchattributes/README.md new file mode 100644 index 00000000..25320a95 --- /dev/null +++ b/typed-searchattributes/README.md @@ -0,0 +1,14 @@ +### Typed Search Attributes Sample + +This sample shows how to use and test the Typed Search Attributes API. + +### Steps to run this sample: +1) Run a [Temporal service](https://github.com/temporalio/samples-go/tree/main/#how-to-use). +2) Run the following command to start the worker: +``` +go run typed-searchattributes/worker/main.go +``` +3) Run the following command to start the example: +``` +go run typed-searchattributes/starter/main.go +``` diff --git a/typed-searchattributes/searchattributes_workflow.go b/typed-searchattributes/searchattributes_workflow.go new file mode 100644 index 00000000..252e73d3 --- /dev/null +++ b/typed-searchattributes/searchattributes_workflow.go @@ -0,0 +1,109 @@ +package typedsearchattributes + +import ( + "errors" + "fmt" + "strings" + "time" + + "go.temporal.io/sdk/log" + "go.temporal.io/sdk/temporal" + "go.temporal.io/sdk/workflow" +) + +/* + * This sample shows how to use the typed search attributes API. + */ + +var ( + // CustomIntKey is the key for a custom int search attribute. + CustomIntKey = temporal.NewSearchAttributeKeyInt64("CustomIntField") + // CustomKeyword is the key for a custom keyword search attribute. + CustomKeyword = temporal.NewSearchAttributeKeyString("CustomKeywordField") + // CustomBool is the key for a custom bool search attribute. + CustomBool = temporal.NewSearchAttributeKeyBool("CustomBoolField") + // CustomDouble is the key for a custom double search attribute. + CustomDouble = temporal.NewSearchAttributeKeyFloat64("CustomDoubleField") + // CustomStringField is the key for a custom string search attribute. + CustomStringField = temporal.NewSearchAttributeKeyString("CustomStringField") + // CustomDatetimeField is the key for a custom datetime search attribute. + CustomDatetimeField = temporal.NewSearchAttributeKeyTime("CustomDatetimeField") +) + +// SearchAttributesWorkflow workflow definition +func SearchAttributesWorkflow(ctx workflow.Context) error { + logger := workflow.GetLogger(ctx) + logger.Info("SearchAttributes workflow started") + + // Get search attributes that were provided when workflow was started. + searchAttributes := workflow.GetTypedSearchAttributes(ctx) + currentIntValue, ok := searchAttributes.GetInt64(CustomIntKey) + if !ok { + return errors.New("CustomIntField is not set") + } + logger.Info("Current search attribute value.", "CustomIntField", currentIntValue) + + // Upsert search attributes. + + // This won't persist search attributes on server because commands are not sent to server, + // but local cache will be updated. + err := workflow.UpsertTypedSearchAttributes(ctx, + CustomIntKey.ValueSet(2), + CustomKeyword.ValueSet("Update1"), + CustomBool.ValueSet(true), + CustomDouble.ValueSet(3.14), + CustomDatetimeField.ValueSet(workflow.Now(ctx).UTC()), + CustomStringField.ValueSet("String field is for text. When query, it will be tokenized for partial match."), + ) + if err != nil { + return err + } + + // Print current search attributes with modifications above. + searchAttributes = workflow.GetTypedSearchAttributes(ctx) + err = printSearchAttributes(searchAttributes, logger) + if err != nil { + return err + } + + // Update search attributes again. + err = workflow.UpsertTypedSearchAttributes(ctx, + CustomKeyword.ValueSet("Update2"), + CustomIntKey.ValueUnset(), + ) + if err != nil { + return err + } + + // Sleep to allow update to be visible in search. + err = workflow.Sleep(ctx, 1*time.Second) + if err != nil { + return err + } + + // Print current search attributes. + searchAttributes = workflow.GetTypedSearchAttributes(ctx) + err = printSearchAttributes(searchAttributes, logger) + if err != nil { + return err + } + + logger.Info("Workflow completed.") + return nil +} + +func printSearchAttributes(searchAttributes temporal.SearchAttributes, logger log.Logger) error { + //workflowcheck:ignore + if searchAttributes.Size() == 0 { + logger.Info("Current search attributes are empty.") + return nil + } + + var builder strings.Builder + //workflowcheck:ignore Only iterates for logging reasons + for k, v := range searchAttributes.GetUntypedValues() { + builder.WriteString(fmt.Sprintf("%s=%v\n", k.GetName(), v)) + } + logger.Info(fmt.Sprintf("Current search attribute values:\n%s", builder.String())) + return nil +} diff --git a/typed-searchattributes/searchattributes_workflow_test.go b/typed-searchattributes/searchattributes_workflow_test.go new file mode 100644 index 00000000..9743db1e --- /dev/null +++ b/typed-searchattributes/searchattributes_workflow_test.go @@ -0,0 +1,38 @@ +package typedsearchattributes + +import ( + "testing" + + "github.com/stretchr/testify/require" + "go.temporal.io/sdk/temporal" + "go.temporal.io/sdk/testsuite" +) + +func Test_Workflow(t *testing.T) { + testSuite := &testsuite.WorkflowTestSuite{} + env := testSuite.NewTestWorkflowEnvironment() + + // mock search attributes on start + _ = env.SetTypedSearchAttributesOnStart(temporal.NewSearchAttributes(CustomIntKey.ValueSet(1))) + + // mock upsert operations + env.OnUpsertTypedSearchAttributes( + temporal.NewSearchAttributes( + CustomIntKey.ValueSet(2), + CustomKeyword.ValueSet("Update1"), + CustomBool.ValueSet(true), + CustomDouble.ValueSet(3.14), + CustomDatetimeField.ValueSet(env.Now().UTC()), + CustomStringField.ValueSet("String field is for text. When query, it will be tokenized for partial match."), + )).Return(nil).Once() + + env.OnUpsertTypedSearchAttributes( + temporal.NewSearchAttributes( + CustomKeyword.ValueSet("Update2"), + CustomIntKey.ValueUnset(), + )).Return(nil).Once() + + env.ExecuteWorkflow(SearchAttributesWorkflow) + require.True(t, env.IsWorkflowCompleted()) + require.NoError(t, env.GetWorkflowError()) +} diff --git a/typed-searchattributes/starter/main.go b/typed-searchattributes/starter/main.go new file mode 100644 index 00000000..f3eb41b0 --- /dev/null +++ b/typed-searchattributes/starter/main.go @@ -0,0 +1,35 @@ +package main + +import ( + "context" + "log" + + "github.com/pborman/uuid" + "go.temporal.io/sdk/client" + "go.temporal.io/sdk/temporal" + + typedsearchattributes "github.com/temporalio/samples-go/typed-searchattributes" +) + +func main() { + // The client is a heavyweight object that should be created once per process. + c, err := client.Dial(client.Options{ + HostPort: client.DefaultHostPort, + }) + if err != nil { + log.Fatalln("Unable to create client", err) + } + defer c.Close() + + workflowOptions := client.StartWorkflowOptions{ + ID: "typed-search_attributes_" + uuid.New(), + TaskQueue: "typed-search-attributes", + TypedSearchAttributes: temporal.NewSearchAttributes(typedsearchattributes.CustomIntKey.ValueSet(1)), + } + + we, err := c.ExecuteWorkflow(context.Background(), workflowOptions, typedsearchattributes.SearchAttributesWorkflow) + if err != nil { + log.Fatalln("Unable to execute workflow", err) + } + log.Println("Started workflow", "WorkflowID", we.GetID(), "RunID", we.GetRunID()) +} diff --git a/typed-searchattributes/worker/main.go b/typed-searchattributes/worker/main.go new file mode 100644 index 00000000..420abd35 --- /dev/null +++ b/typed-searchattributes/worker/main.go @@ -0,0 +1,30 @@ +package main + +import ( + "log" + + "go.temporal.io/sdk/client" + "go.temporal.io/sdk/worker" + + typedsearchattributes "github.com/temporalio/samples-go/typed-searchattributes" +) + +func main() { + // The client and worker are heavyweight objects that should be created once per process. + c, err := client.Dial(client.Options{ + HostPort: client.DefaultHostPort, + }) + if err != nil { + log.Fatalln("Unable to create client", err) + } + defer c.Close() + + w := worker.New(c, "typed-search-attributes", worker.Options{}) + + w.RegisterWorkflow(typedsearchattributes.SearchAttributesWorkflow) + + err = w.Run(worker.InterruptCh()) + if err != nil { + log.Fatalln("Unable to start worker", err) + } +}