Skip to content

Commit ca8bf64

Browse files
committed
Support openapiv2 proto annotations from sdk-core#1172
sdk-core added protoc-gen-openapiv2 imports to cloud service protos. This broke proto generation in two ways: 1. protoc couldn't resolve the import — none of the existing --proto_path entries point to a directory where protoc-gen-openapiv2/ is a child. Fix: add protos/ as --proto_path, but only for the cloud protos call (via extra_proto_paths param). Adding it globally causes duplicate definition errors since files under api_upstream/ become reachable through both protos/api_upstream and protos/. 2. The generated service.rb requires the openapiv2 Ruby files, which didn't exist. generate_service_files loads service.rb to reflect on the service descriptor, so the missing require crashes the build. Fix: generate openapiv2 protos into lib/protoc-gen-openapiv2/. Mirrors sdk-dotnet#633.
1 parent 32bed58 commit ca8bf64

15 files changed

Lines changed: 493 additions & 9 deletions

File tree

temporalio/ext/src/client_rpc_generated.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,14 @@ impl Client {
976976
cloud_service,
977977
add_user_group_member
978978
),
979+
"create_account_audit_log_sink" => rpc_call!(
980+
self,
981+
callback,
982+
call,
983+
CloudService,
984+
cloud_service,
985+
create_account_audit_log_sink
986+
),
979987
"create_api_key" => rpc_call!(
980988
self,
981989
callback,
@@ -984,6 +992,14 @@ impl Client {
984992
cloud_service,
985993
create_api_key
986994
),
995+
"create_billing_report" => rpc_call!(
996+
self,
997+
callback,
998+
call,
999+
CloudService,
1000+
cloud_service,
1001+
create_billing_report
1002+
),
9871003
"create_connectivity_rule" => rpc_call!(
9881004
self,
9891005
callback,
@@ -1040,6 +1056,14 @@ impl Client {
10401056
cloud_service,
10411057
create_user_group
10421058
),
1059+
"delete_account_audit_log_sink" => rpc_call!(
1060+
self,
1061+
callback,
1062+
call,
1063+
CloudService,
1064+
cloud_service,
1065+
delete_account_audit_log_sink
1066+
),
10431067
"delete_api_key" => rpc_call!(
10441068
self,
10451069
callback,
@@ -1128,6 +1152,22 @@ impl Client {
11281152
cloud_service,
11291153
get_account
11301154
),
1155+
"get_account_audit_log_sink" => rpc_call!(
1156+
self,
1157+
callback,
1158+
call,
1159+
CloudService,
1160+
cloud_service,
1161+
get_account_audit_log_sink
1162+
),
1163+
"get_account_audit_log_sinks" => rpc_call!(
1164+
self,
1165+
callback,
1166+
call,
1167+
CloudService,
1168+
cloud_service,
1169+
get_account_audit_log_sinks
1170+
),
11311171
"get_api_key" => rpc_call!(
11321172
self,
11331173
callback,
@@ -1152,6 +1192,22 @@ impl Client {
11521192
cloud_service,
11531193
get_async_operation
11541194
),
1195+
"get_audit_logs" => rpc_call!(
1196+
self,
1197+
callback,
1198+
call,
1199+
CloudService,
1200+
cloud_service,
1201+
get_audit_logs
1202+
),
1203+
"get_billing_report" => rpc_call!(
1204+
self,
1205+
callback,
1206+
call,
1207+
CloudService,
1208+
cloud_service,
1209+
get_billing_report
1210+
),
11551211
"get_connectivity_rule" => rpc_call!(
11561212
self,
11571213
callback,
@@ -1168,6 +1224,14 @@ impl Client {
11681224
cloud_service,
11691225
get_connectivity_rules
11701226
),
1227+
"get_current_identity" => rpc_call!(
1228+
self,
1229+
callback,
1230+
call,
1231+
CloudService,
1232+
cloud_service,
1233+
get_current_identity
1234+
),
11711235
"get_namespace" => rpc_call!(
11721236
self,
11731237
callback,
@@ -1176,6 +1240,14 @@ impl Client {
11761240
cloud_service,
11771241
get_namespace
11781242
),
1243+
"get_namespace_capacity_info" => rpc_call!(
1244+
self,
1245+
callback,
1246+
call,
1247+
CloudService,
1248+
cloud_service,
1249+
get_namespace_capacity_info
1250+
),
11791251
"get_namespace_export_sink" => rpc_call!(
11801252
self,
11811253
callback,
@@ -1329,6 +1401,14 @@ impl Client {
13291401
cloud_service,
13301402
update_account
13311403
),
1404+
"update_account_audit_log_sink" => rpc_call!(
1405+
self,
1406+
callback,
1407+
call,
1408+
CloudService,
1409+
cloud_service,
1410+
update_account_audit_log_sink
1411+
),
13321412
"update_api_key" => rpc_call!(
13331413
self,
13341414
callback,

temporalio/ext/src/metric.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ static METRIC_BUFFER_METRIC: Lazy<RClass> = Lazy::new(|ruby| {
320320
static METRIC_KIND_COUNTER: Lazy<StaticSymbol> = Lazy::new(|ruby| ruby.sym_new("counter"));
321321
static METRIC_KIND_GAUGE: Lazy<StaticSymbol> = Lazy::new(|ruby| ruby.sym_new("gauge"));
322322
static METRIC_KIND_HISTOGRAM: Lazy<StaticSymbol> = Lazy::new(|ruby| ruby.sym_new("histogram"));
323-
static METRIC_KIND_UP_DOWN_COUNTER: Lazy<StaticSymbol> = Lazy::new(|ruby| ruby.sym_new("up_down_counter"));
323+
static METRIC_KIND_UP_DOWN_COUNTER: Lazy<StaticSymbol> =
324+
Lazy::new(|ruby| ruby.sym_new("up_down_counter"));
324325

325326
pub fn convert_metric_events(
326327
ruby: &Ruby,

temporalio/extra/proto_gen.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ def run
1212
generate_api_protos(Dir.glob('ext/sdk-core/crates/common/protos/api_upstream/**/*.proto').reject do |proto|
1313
proto.include?('google')
1414
end)
15-
generate_api_protos(Dir.glob('ext/sdk-core/crates/common/protos/api_cloud_upstream/**/*.proto'))
15+
generate_openapiv2_protos
16+
generate_api_protos(
17+
Dir.glob('ext/sdk-core/crates/common/protos/api_cloud_upstream/**/*.proto'),
18+
extra_proto_paths: ['--proto_path=ext/sdk-core/crates/common/protos']
19+
)
1620
generate_api_protos(Dir.glob('ext/sdk-core/crates/common/protos/testsrv_upstream/**/*.proto'))
1721
generate_api_protos(Dir.glob('ext/additional_protos/**/*.proto'))
1822
generate_import_helper_files
@@ -24,7 +28,7 @@ def run
2428

2529
private
2630

27-
def generate_api_protos(api_protos)
31+
def generate_api_protos(api_protos, extra_proto_paths: [])
2832
# Generate API to temp dir and move
2933
FileUtils.rm_rf('tmp-proto')
3034
FileUtils.mkdir_p('tmp-proto')
@@ -36,6 +40,7 @@ def generate_api_protos(api_protos)
3640
'--proto_path=ext/sdk-core/crates/common/protos/api_cloud_upstream',
3741
'--proto_path=ext/sdk-core/crates/common/protos/testsrv_upstream',
3842
'--proto_path=ext/additional_protos',
43+
*extra_proto_paths,
3944
'--ruby_out=tmp-proto',
4045
*api_protos,
4146
exception: true
@@ -57,6 +62,22 @@ def generate_api_protos(api_protos)
5762
FileUtils.rm_rf('tmp-proto')
5863
end
5964

65+
def generate_openapiv2_protos
66+
FileUtils.rm_rf('tmp-proto')
67+
FileUtils.mkdir_p('tmp-proto')
68+
system(
69+
'bundle',
70+
'exec',
71+
'grpc_tools_ruby_protoc',
72+
'--proto_path=ext/sdk-core/crates/common/protos',
73+
'--ruby_out=tmp-proto',
74+
*Dir.glob('ext/sdk-core/crates/common/protos/protoc-gen-openapiv2/**/*.proto'),
75+
exception: true
76+
)
77+
FileUtils.cp_r('tmp-proto/protoc-gen-openapiv2', 'lib')
78+
FileUtils.rm_rf('tmp-proto')
79+
end
80+
6081
def generate_import_helper_files
6182
# Write files that will help with imports. We are requiring the
6283
# request_response and not the service because the service depends on Google

temporalio/lib/protoc-gen-openapiv2/options/annotations_pb.rb

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)