Skip to content

Commit

Permalink
Rename to remote state
Browse files Browse the repository at this point in the history
  • Loading branch information
amh4r committed Oct 23, 2024
1 parent cb5de59 commit 7255aa0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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__(
Expand All @@ -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:
----
Expand All @@ -84,7 +86,7 @@ def factory(
def _factory(
client: inngest.Inngest,
raw_request: object,
) -> ExternalStateMiddleware:
) -> RemoteStateMiddleware:
return cls(
client,
raw_request,
Expand All @@ -100,7 +102,7 @@ def transform_input(
steps: inngest.StepMemos,
) -> None:
"""
Inject external state.
Inject remote state.
"""

for step in steps.values():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down Expand Up @@ -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),
)
Expand All @@ -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),
)
Expand Down

0 comments on commit 7255aa0

Please sign in to comment.