|
1 | 1 | package main |
2 | 2 |
|
3 | | -import "io" |
| 3 | +import ( |
| 4 | + "io" |
| 5 | +) |
4 | 6 |
|
5 | 7 | var ( |
6 | 8 | lazyClientMap = map[string]string{ |
7 | 9 | "admin": "GetAdminClient", |
8 | 10 | "frontend": "GetWorkflowServiceClient", |
9 | 11 | } |
| 12 | + |
| 13 | + ignoreMethodsNotIn122 = map[string]bool{ |
| 14 | + // adminservice methods |
| 15 | + "AddTasks": true, |
| 16 | + "CancelDLQJob": true, |
| 17 | + "DeepHealthCheck": true, |
| 18 | + "DescribeDLQJob": true, |
| 19 | + "DescribeTaskQueuePartition": true, |
| 20 | + "ForceUnloadTaskQueuePartition": true, |
| 21 | + "GenerateLastHistoryReplicationTasks": true, |
| 22 | + "GetDLQTasks": true, |
| 23 | + "GetWorkflowExecutionRawHistory": true, |
| 24 | + "ImportWorkflowExecution": true, |
| 25 | + "ListQueues": true, |
| 26 | + "MergeDLQTasks": true, |
| 27 | + "PurgeDLQTasks": true, |
| 28 | + "SyncWorkflowState": true, |
| 29 | + |
| 30 | + // workflowservice |
| 31 | + "DescribeDeployment": true, |
| 32 | + "ExecuteMultiOperation": true, |
| 33 | + "GetCurrentDeployment": true, |
| 34 | + "GetDeploymentReachability": true, |
| 35 | + "GetWorkerVersioningRules": true, |
| 36 | + "ListDeployments": true, |
| 37 | + "PauseActivityById": true, |
| 38 | + "PollNexusTaskQueue": true, |
| 39 | + "ResetActivityById": true, |
| 40 | + "RespondNexusTaskCompleted": true, |
| 41 | + "RespondNexusTaskFailed": true, |
| 42 | + "SetCurrentDeployment": true, |
| 43 | + "ShutdownWorker": true, |
| 44 | + "UnpauseActivityById": true, |
| 45 | + "UpdateActivityOptionsById": true, |
| 46 | + "UpdateWorkerVersioningRules": true, |
| 47 | + "UpdateWorkflowExecutionOptions": true, |
| 48 | + } |
10 | 49 | ) |
11 | 50 |
|
12 | 51 | func init() { |
@@ -59,3 +98,43 @@ func (c *lazyClient) {{.Method}}( |
59 | 98 | } |
60 | 99 | `) |
61 | 100 | } |
| 101 | + |
| 102 | +func generate122ConversionCode(w io.Writer, service service) { |
| 103 | + writeTemplatedCode(w, service, ` |
| 104 | +package compat |
| 105 | +import ( |
| 106 | + svc "{{.ServicePackagePath}}" |
| 107 | + svc122 "{{.ServicePackagePath122}}" |
| 108 | + "github.com/temporalio/s2s-proxy/common" |
| 109 | +) |
| 110 | +
|
| 111 | +// {{.ServiceNameTitle}}ConvertTo122 accepts a protobuf type and returns |
| 112 | +// the corresponding gogo-based protobuf type from Temporal v1.22. |
| 113 | +func {{.ServiceNameTitle}}ConvertTo122(vAny any) (common.Marshaler, bool) { |
| 114 | + switch vAny.(type) { |
| 115 | +`) |
| 116 | + |
| 117 | + writeTemplatedMethods122(w, service, "conversion", ` |
| 118 | +case *svc.{{.Method}}Response: |
| 119 | + return &svc122.{{.Method}}Response{}, true |
| 120 | +case *svc.{{.Method}}Request: |
| 121 | + return &svc122.{{.Method}}Request{}, true |
| 122 | +`) |
| 123 | + |
| 124 | + writeTemplatedCode(w, service, `} |
| 125 | + return nil, false |
| 126 | +} |
| 127 | +`) |
| 128 | +} |
| 129 | + |
| 130 | +func writeTemplatedMethods122(w io.Writer, service service, impl string, text string) { |
| 131 | + sType := service.clientType.Elem() |
| 132 | + for n := 0; n < sType.NumMethod(); n++ { |
| 133 | + m := sType.Method(n) |
| 134 | + if ignoreMethodsNotIn122[m.Name] { |
| 135 | + continue |
| 136 | + } |
| 137 | + |
| 138 | + writeTemplatedMethod(w, service, impl, m, text) |
| 139 | + } |
| 140 | +} |
0 commit comments