diff --git a/api/bank/v1/account.proto b/api/bank/v1/account.proto index f6ede0e..21b4854 100644 --- a/api/bank/v1/account.proto +++ b/api/bank/v1/account.proto @@ -11,7 +11,7 @@ import "bank/v1/errors.proto"; // State machine definition. message Account { - option (.rbt.v1alpha1.state) = { + option (rbt.v1alpha1.state) = { }; string customer_name = 1; uint64 balance = 2; diff --git a/api/bank/v1/bank.proto b/api/bank/v1/bank.proto index 5b3cc80..18aa615 100644 --- a/api/bank/v1/bank.proto +++ b/api/bank/v1/bank.proto @@ -25,7 +25,7 @@ service BankInterface { //////////////////////////////////////////////////////////////////////// message Bank { - option (.rbt.v1alpha1.state) = { + option (rbt.v1alpha1.state) = { }; repeated string account_ids = 1; } diff --git a/api/hello_constructors/v1/hello.proto b/api/hello_constructors/v1/hello.proto index d5cf15a..d500e38 100644 --- a/api/hello_constructors/v1/hello.proto +++ b/api/hello_constructors/v1/hello.proto @@ -28,7 +28,7 @@ service HelloInterface { } message Hello { - option (.rbt.v1alpha1.state) = { + option (rbt.v1alpha1.state) = { }; repeated string messages = 2; } diff --git a/api/hello_legacy_grpc/v1/greeter.proto b/api/hello_legacy_grpc/v1/greeter.proto index b718612..306a9ad 100644 --- a/api/hello_legacy_grpc/v1/greeter.proto +++ b/api/hello_legacy_grpc/v1/greeter.proto @@ -41,7 +41,7 @@ service ProxyGreeter { } message RebootGreeter { - option (.rbt.v1alpha1.state) = { + option (rbt.v1alpha1.state) = { }; int32 num_greetings = 1; } diff --git a/api/hello_tasks/v1/hello.proto b/api/hello_tasks/v1/hello.proto index e7763c7..3bf50bb 100644 --- a/api/hello_tasks/v1/hello.proto +++ b/api/hello_tasks/v1/hello.proto @@ -42,7 +42,7 @@ message Message { } message Hello { - option (.rbt.v1alpha1.state) = { + option (rbt.v1alpha1.state) = { }; repeated Message messages = 1; int32 num_erased_messages = 2; diff --git a/bank/.rbtrc b/bank/.rbtrc index c2da1f2..b0f639e 100644 --- a/bank/.rbtrc +++ b/bank/.rbtrc @@ -35,4 +35,4 @@ dev run --watch=backend/**/*.py dev run --python # Run the application! -dev run backend/src/main.py +dev run --application=backend/src/main.py diff --git a/hello-constructors/.rbtrc b/hello-constructors/.rbtrc index c2da1f2..b0f639e 100644 --- a/hello-constructors/.rbtrc +++ b/hello-constructors/.rbtrc @@ -35,4 +35,4 @@ dev run --watch=backend/**/*.py dev run --python # Run the application! -dev run backend/src/main.py +dev run --application=backend/src/main.py diff --git a/hello-legacy-grpc/.rbtrc b/hello-legacy-grpc/.rbtrc index c2da1f2..b0f639e 100644 --- a/hello-legacy-grpc/.rbtrc +++ b/hello-legacy-grpc/.rbtrc @@ -35,4 +35,4 @@ dev run --watch=backend/**/*.py dev run --python # Run the application! -dev run backend/src/main.py +dev run --application=backend/src/main.py diff --git a/hello-legacy-grpc/backend/src/main.py b/hello-legacy-grpc/backend/src/main.py index fb26381..7f8b1e7 100755 --- a/hello-legacy-grpc/backend/src/main.py +++ b/hello-legacy-grpc/backend/src/main.py @@ -1,4 +1,5 @@ import asyncio +import reboot.aio.memoize from deprecated_greeter_servicer import DeprecatedGreeterServicer from hello_legacy_grpc.v1.greeter_rbt import RebootGreeter from proxy_greeter_servicer import ProxyGreeterServicer @@ -24,7 +25,7 @@ async def initialize(context: ExternalContext): async def main(): await Application( - servicers=[RebootGreeterServicer], + servicers=[RebootGreeterServicer] + reboot.aio.memoize.servicers(), legacy_grpc_servicers=[ DeprecatedGreeterServicer, ProxyGreeterServicer ], diff --git a/hello-legacy-grpc/backend/src/reboot_greeter_servicer.py b/hello-legacy-grpc/backend/src/reboot_greeter_servicer.py index 4b324a7..73759ca 100644 --- a/hello-legacy-grpc/backend/src/reboot_greeter_servicer.py +++ b/hello-legacy-grpc/backend/src/reboot_greeter_servicer.py @@ -13,6 +13,7 @@ WorkflowContext, WriterContext, ) +from reboot.aio.memoize import at_most_once logging.basicConfig(level=logging.INFO) @@ -78,22 +79,21 @@ async def Initialize( context: WorkflowContext, request: Empty, ): - # Call the ProxyGreeter service for a few greetings. - # - # NOTE: we don't currently have a way to call legacy gRPC - # _idempotently_ (that's one of the reasons for Reboot!), so - # for now we assume/hope that this workflow won't get retried - # due to a failure but it's totally possible and if it happens - # we might perform extra greets! - async with context.legacy_grpc_channel() as channel: - proxy_greeter_stub = greeter_pb2_grpc.ProxyGreeterStub(channel) - for i in range(10): - greet_response = await proxy_greeter_stub.Greet( - greeter_pb2.GreetRequest(name="legacy gRPC") - ) - logging.info( - f"Received a greeting: '{greet_response.message}'" - ) + async def make_greetings(): + """Calls the ProxyGreeter service for a few greetings.""" + async with context.legacy_grpc_channel() as channel: + proxy_greeter_stub = greeter_pb2_grpc.ProxyGreeterStub(channel) + + for i in range(10): + greet_response = await proxy_greeter_stub.Greet( + greeter_pb2.GreetRequest(name="legacy gRPC") + ) + logging.info( + f"Received a greeting: '{greet_response.message}'" + ) + + # We only want to make the greetings at-most-once. + await at_most_once("make greetings", context, make_greetings) return Empty() diff --git a/hello-tasks/.rbtrc b/hello-tasks/.rbtrc index 66a0551..375251a 100644 --- a/hello-tasks/.rbtrc +++ b/hello-tasks/.rbtrc @@ -35,4 +35,4 @@ dev run --watch=backend/**/*.py dev run --python # Run the application! -dev run backend/src/main.py +dev run --application=backend/src/main.py diff --git a/pyproject.toml b/pyproject.toml index fddcc19..85cd0d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] requires-python = ">= 3.10" dependencies = [ - "reboot==0.15.0", + "reboot==0.16.0", ] [tool.rye] @@ -9,7 +9,7 @@ dev-dependencies = [ "mypy==1.2.0", "pytest>=7.4.2", "types-protobuf>=4.24.0.20240129", - "reboot==0.15.0", + "reboot==0.16.0", ] # This project only uses `rye` to provide `python` and its dependencies, so diff --git a/requirements-dev.lock b/requirements-dev.lock index a54b5b4..505929c 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -108,7 +108,7 @@ python-dateutil==2.9.0.post0 pyyaml==6.0.2 # via kubernetes-asyncio # via reboot -reboot==0.15.0 +reboot==0.16.0 setuptools==75.1.0 # via grpcio-tools six==1.16.0 diff --git a/requirements.lock b/requirements.lock index 4d56548..0a3f214 100644 --- a/requirements.lock +++ b/requirements.lock @@ -97,7 +97,7 @@ python-dateutil==2.9.0.post0 pyyaml==6.0.2 # via kubernetes-asyncio # via reboot -reboot==0.15.0 +reboot==0.16.0 setuptools==75.1.0 # via grpcio-tools six==1.16.0