From 81b35ee85bd63998c85430bc26a9559f90b14c88 Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Tue, 11 Jun 2024 14:10:05 +1000 Subject: [PATCH 1/8] Deprecate the bytes coroutine_state in favor of google.protobuf.Any --- dispatch/sdk/v1/poll.proto | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dispatch/sdk/v1/poll.proto b/dispatch/sdk/v1/poll.proto index e5ecd4d..0a48a2d 100644 --- a/dispatch/sdk/v1/poll.proto +++ b/dispatch/sdk/v1/poll.proto @@ -5,13 +5,14 @@ package dispatch.sdk.v1; import "buf/validate/validate.proto"; import "dispatch/sdk/v1/call.proto"; import "dispatch/sdk/v1/error.proto"; +import "google/protobuf/any.proto"; import "google/protobuf/duration.proto"; // Poll is a directive to make asynchronous calls and join on their results. message Poll { // Snapshot of the coroutine state that will be used in the next run to // resume the function. - bytes coroutine_state = 1; + bytes coroutine_state = 1 [deprecated = true]; // Calls to make asynchronously. repeated Call calls = 2; @@ -39,13 +40,16 @@ message Poll { (buf.validate.field).int32.gte = 1, (buf.validate.field).int32.lte = 1000 ]; + + // State of the function. The same state is sent back on the PollResult. + google.protobuf.Any state = 6; } // PollResult is the response to a Poll directive. message PollResult { // The coroutine state that was recorded by the coroutine when it was last // paused. - bytes coroutine_state = 1; + bytes coroutine_state = 1 [deprecated = true]; // The list of results from calls that were made by the coroutine and // completed during the poll. @@ -55,4 +59,7 @@ message PollResult { // that none of the calls were dispatched, and must be resubmitted // after the error cause has been resolved. Error error = 3; + + // State of the function when polling. + google.protobuf.Any state = 4; } From b88299c166174f727ccfc057e2659161d064b87f Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Tue, 11 Jun 2024 14:11:24 +1000 Subject: [PATCH 2/8] Add a wrapper for pickled values --- dispatch/sdk/v1/object/python/pickled.proto | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 dispatch/sdk/v1/object/python/pickled.proto diff --git a/dispatch/sdk/v1/object/python/pickled.proto b/dispatch/sdk/v1/object/python/pickled.proto new file mode 100644 index 0000000..cf09c3f --- /dev/null +++ b/dispatch/sdk/v1/object/python/pickled.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package dispatch.sdk.v1.object.python; + +// Pickled is a wrapper for a value that was serialized with +// the Python pickle package. +message Pickled { + // Pickled representation of a value. + bytes pickled_value = 1; +} From c23180e2573aaff9008239f7bd68346341eabedf Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Tue, 11 Jun 2024 14:20:30 +1000 Subject: [PATCH 3/8] Lint --- .../sdk/{v1/object/python => object/python/v1}/pickled.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename dispatch/sdk/{v1/object/python => object/python/v1}/pickled.proto (83%) diff --git a/dispatch/sdk/v1/object/python/pickled.proto b/dispatch/sdk/object/python/v1/pickled.proto similarity index 83% rename from dispatch/sdk/v1/object/python/pickled.proto rename to dispatch/sdk/object/python/v1/pickled.proto index cf09c3f..14e348a 100644 --- a/dispatch/sdk/v1/object/python/pickled.proto +++ b/dispatch/sdk/object/python/v1/pickled.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package dispatch.sdk.v1.object.python; +package dispatch.sdk.object.python.v1; // Pickled is a wrapper for a value that was serialized with // the Python pickle package. From fb5b1bfa6fcb22123cc261f582ebd98f62d57bb7 Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Tue, 11 Jun 2024 14:22:16 +1000 Subject: [PATCH 4/8] Drop object --- dispatch/sdk/{object => }/python/v1/pickled.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename dispatch/sdk/{object => }/python/v1/pickled.proto (83%) diff --git a/dispatch/sdk/object/python/v1/pickled.proto b/dispatch/sdk/python/v1/pickled.proto similarity index 83% rename from dispatch/sdk/object/python/v1/pickled.proto rename to dispatch/sdk/python/v1/pickled.proto index 14e348a..f3c23ee 100644 --- a/dispatch/sdk/object/python/v1/pickled.proto +++ b/dispatch/sdk/python/v1/pickled.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package dispatch.sdk.object.python.v1; +package dispatch.sdk.python.v1; // Pickled is a wrapper for a value that was serialized with // the Python pickle package. From 8669b0b48270240e8acfca0ae927aef685791a23 Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Wed, 12 Jun 2024 09:10:09 +1000 Subject: [PATCH 5/8] Allow either typed or untyped coroutine state --- dispatch/sdk/v1/poll.proto | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dispatch/sdk/v1/poll.proto b/dispatch/sdk/v1/poll.proto index 0a48a2d..f29e8a6 100644 --- a/dispatch/sdk/v1/poll.proto +++ b/dispatch/sdk/v1/poll.proto @@ -12,7 +12,10 @@ import "google/protobuf/duration.proto"; message Poll { // Snapshot of the coroutine state that will be used in the next run to // resume the function. - bytes coroutine_state = 1 [deprecated = true]; + oneof state { + bytes coroutine_state = 1; + google.protobuf.Any typed_coroutine_state = 6; + } // Calls to make asynchronously. repeated Call calls = 2; @@ -42,14 +45,16 @@ message Poll { ]; // State of the function. The same state is sent back on the PollResult. - google.protobuf.Any state = 6; } // PollResult is the response to a Poll directive. message PollResult { // The coroutine state that was recorded by the coroutine when it was last // paused. - bytes coroutine_state = 1 [deprecated = true]; + oneof state { + bytes coroutine_state = 1; + google.protobuf.Any typed_coroutine_state = 4; + } // The list of results from calls that were made by the coroutine and // completed during the poll. @@ -59,7 +64,4 @@ message PollResult { // that none of the calls were dispatched, and must be resubmitted // after the error cause has been resolved. Error error = 3; - - // State of the function when polling. - google.protobuf.Any state = 4; } From e9328d321b6f82c72a1f7f78ebe055fcdc0b8c94 Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Wed, 12 Jun 2024 09:11:58 +1000 Subject: [PATCH 6/8] Relax the breaking change detection See https://buf.build/docs/breaking/rules --- buf.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buf.yaml b/buf.yaml index b2e72dc..4f4218c 100644 --- a/buf.yaml +++ b/buf.yaml @@ -4,7 +4,7 @@ deps: - buf.build/bufbuild/protovalidate breaking: use: - - FILE + - WIRE_JSON lint: use: - DEFAULT From 6e036ff38dd43565655ff29e488166ad3cc22e2c Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Wed, 12 Jun 2024 09:16:47 +1000 Subject: [PATCH 7/8] Disable the FIELD_SAME_ONEOF breaking change rule See https://buf.build/docs/breaking/rules#field_same_oneof. The exception they mention applies to the current branch. Disable the rule temporarily so that we can get the change through. --- buf.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buf.yaml b/buf.yaml index 4f4218c..bfe823f 100644 --- a/buf.yaml +++ b/buf.yaml @@ -5,6 +5,8 @@ deps: breaking: use: - WIRE_JSON + except: + - FIELD_SAME_ONEOF lint: use: - DEFAULT From 62e5f53acead757fbfb5d77cd06672be2a305901 Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Wed, 12 Jun 2024 09:24:46 +1000 Subject: [PATCH 8/8] Remove stray comment --- dispatch/sdk/v1/poll.proto | 2 -- 1 file changed, 2 deletions(-) diff --git a/dispatch/sdk/v1/poll.proto b/dispatch/sdk/v1/poll.proto index f29e8a6..d51fc50 100644 --- a/dispatch/sdk/v1/poll.proto +++ b/dispatch/sdk/v1/poll.proto @@ -43,8 +43,6 @@ message Poll { (buf.validate.field).int32.gte = 1, (buf.validate.field).int32.lte = 1000 ]; - - // State of the function. The same state is sent back on the PollResult. } // PollResult is the response to a Poll directive.