From 7255aa0445d4afdb047442271103e0b4bca55169 Mon Sep 17 00:00:00 2001 From: Aaron Harper Date: Wed, 23 Oct 2024 09:27:01 -0400 Subject: [PATCH] Rename to remote state --- ...ddleware.py => remote_state_middleware.py} | 22 ++++++++++--------- .../__init__.py | 0 .../cases/__init__.py | 0 .../cases/base.py | 0 .../cases/step_output.py | 8 +++---- .../test_flask.py | 0 6 files changed, 16 insertions(+), 14 deletions(-) rename inngest/experimental/{external_state_middleware.py => remote_state_middleware.py} (79%) rename tests/test_experimental/{test_external_state_middleware => test_remote_state_middleware}/__init__.py (100%) rename tests/test_experimental/{test_external_state_middleware => test_remote_state_middleware}/cases/__init__.py (100%) rename tests/test_experimental/{test_external_state_middleware => test_remote_state_middleware}/cases/base.py (100%) rename tests/test_experimental/{test_external_state_middleware => test_remote_state_middleware}/cases/step_output.py (94%) rename tests/test_experimental/{test_external_state_middleware => test_remote_state_middleware}/test_flask.py (100%) diff --git a/inngest/experimental/external_state_middleware.py b/inngest/experimental/remote_state_middleware.py similarity index 79% rename from inngest/experimental/external_state_middleware.py rename to inngest/experimental/remote_state_middleware.py index a4b26873..5267b98d 100644 --- a/inngest/experimental/external_state_middleware.py +++ b/inngest/experimental/remote_state_middleware.py @@ -1,5 +1,5 @@ """ -External state middleware for Inngest. +Remote state middleware for Inngest. NOT STABLE! This is an experimental feature and may change in the future. If you'd like to use it, we recommend copying this file into your source code. @@ -40,13 +40,15 @@ def write(self, value: object) -> str: ... -# Marker to indicate that the data is stored externally. -_marker: typing.Final = "__EXTERNAL_STATE__" +# Marker to indicate that the data is stored remotely. +_marker: typing.Final = "__REMOTE_STATE__" -class ExternalStateMiddleware(inngest.MiddlewareSync): +class RemoteStateMiddleware(inngest.MiddlewareSync): """ - Middleware that reads/writes step output in an external store. + Middleware that reads/writes step output in a custom store (e.g. AWS S3). + This can drastically reduce bandwidth to/from the Inngest server, since step + output is stored within your infrastructure rather than Inngest's. """ def __init__( @@ -71,10 +73,10 @@ def __init__( def factory( cls, driver: StateDriver, - ) -> typing.Callable[[inngest.Inngest, object], ExternalStateMiddleware]: + ) -> typing.Callable[[inngest.Inngest, object], RemoteStateMiddleware]: """ - Create an external state middleware that can be passed to an Inngest - client or function. + Create a remote state middleware that can be passed to an Inngest client + or function. Args: ---- @@ -84,7 +86,7 @@ def factory( def _factory( client: inngest.Inngest, raw_request: object, - ) -> ExternalStateMiddleware: + ) -> RemoteStateMiddleware: return cls( client, raw_request, @@ -100,7 +102,7 @@ def transform_input( steps: inngest.StepMemos, ) -> None: """ - Inject external state. + Inject remote state. """ for step in steps.values(): diff --git a/tests/test_experimental/test_external_state_middleware/__init__.py b/tests/test_experimental/test_remote_state_middleware/__init__.py similarity index 100% rename from tests/test_experimental/test_external_state_middleware/__init__.py rename to tests/test_experimental/test_remote_state_middleware/__init__.py diff --git a/tests/test_experimental/test_external_state_middleware/cases/__init__.py b/tests/test_experimental/test_remote_state_middleware/cases/__init__.py similarity index 100% rename from tests/test_experimental/test_external_state_middleware/cases/__init__.py rename to tests/test_experimental/test_remote_state_middleware/cases/__init__.py diff --git a/tests/test_experimental/test_external_state_middleware/cases/base.py b/tests/test_experimental/test_remote_state_middleware/cases/base.py similarity index 100% rename from tests/test_experimental/test_external_state_middleware/cases/base.py rename to tests/test_experimental/test_remote_state_middleware/cases/base.py diff --git a/tests/test_experimental/test_external_state_middleware/cases/step_output.py b/tests/test_experimental/test_remote_state_middleware/cases/step_output.py similarity index 94% rename from tests/test_experimental/test_external_state_middleware/cases/step_output.py rename to tests/test_experimental/test_remote_state_middleware/cases/step_output.py index 2cabd965..8116dee6 100644 --- a/tests/test_experimental/test_external_state_middleware/cases/step_output.py +++ b/tests/test_experimental/test_remote_state_middleware/cases/step_output.py @@ -9,8 +9,8 @@ import inngest import tests.helper from inngest._internal import server_lib -from inngest.experimental.external_state_middleware import ( - ExternalStateMiddleware, +from inngest.experimental.remote_state_middleware import ( + RemoteStateMiddleware, StateDriver, ) @@ -52,7 +52,7 @@ def create( @client.create_function( fn_id=fn_id, - middleware=[ExternalStateMiddleware.factory(driver)], + middleware=[RemoteStateMiddleware.factory(driver)], retries=0, trigger=inngest.TriggerEvent(event=event_name), ) @@ -78,7 +78,7 @@ def _step_2() -> list[inngest.JSON]: @client.create_function( fn_id=fn_id, - middleware=[ExternalStateMiddleware.factory(driver)], + middleware=[RemoteStateMiddleware.factory(driver)], retries=0, trigger=inngest.TriggerEvent(event=event_name), ) diff --git a/tests/test_experimental/test_external_state_middleware/test_flask.py b/tests/test_experimental/test_remote_state_middleware/test_flask.py similarity index 100% rename from tests/test_experimental/test_external_state_middleware/test_flask.py rename to tests/test_experimental/test_remote_state_middleware/test_flask.py