Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ doc = false
[dependencies]
pyo3 = { version = "0.25.1", features = ["extension-module"] }
tracing-subscriber = { version = "0.3", features = ["fmt", "env-filter"] }
restate-sdk-shared-core = { version = "7.0.0", features = ["request_identity", "sha2_random_seed", "rust_crypto"] }
restate-sdk-shared-core = { version = "7.0.1", features = ["request_identity", "sha2_random_seed", "rust_crypto"] }
44 changes: 44 additions & 0 deletions python/restate/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,50 @@ async def service_send(
send = typing.cast(typing.Dict[str, str], send_handle)
return RestateClientSendHandle(send.get("invocationId", ""), 200)

async def object_call(
self,
tpe: HandlerType[I, O],
key: str,
arg: I,
limit_key: str | None = None,
idempotency_key: str | None = None,
headers: typing.Dict[str, str] | None = None,
) -> O:
return await self.client.do_call(
tpe,
arg,
key,
idempotency_key=idempotency_key,
headers=headers,
scope=self.scope_key,
limit_key=limit_key,
)

async def object_send(
self,
tpe: HandlerType[I, O],
key: str,
arg: I,
send_delay: typing.Optional[timedelta] = None,
limit_key: str | None = None,
idempotency_key: str | None = None,
headers: typing.Dict[str, str] | None = None,
) -> RestateClientSendHandle:
send_handle = await self.client.do_call(
tpe,
parameter=arg,
key=key,
send=True,
send_delay=send_delay,
idempotency_key=idempotency_key,
headers=headers,
force_json_output=True,
scope=self.scope_key,
limit_key=limit_key,
)
send = typing.cast(typing.Dict[str, str], send_handle)
return RestateClientSendHandle(send.get("invocationId", ""), 200)

async def workflow_call(
self,
tpe: HandlerType[I, O],
Expand Down
37 changes: 37 additions & 0 deletions python/restate/client_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,43 @@ async def service_send(
"""Make a send operation to the given handler, within this scope"""
pass

@abc.abstractmethod
async def object_call(
self,
tpe: HandlerType[I, O],
key: str,
arg: I,
limit_key: str | None = None,
idempotency_key: str | None = None,
headers: typing.Dict[str, str] | None = None,
) -> O:
"""
Make an RPC call to the given object handler, within this scope.

NOTE: To use scopes with virtual objects you must enable the additional experimental feature in restate-server,
via RESTATE_EXPERIMENTAL_ENABLE_SCOPED_VIRTUAL_OBJECTS=true
"""
pass

@abc.abstractmethod
async def object_send(
self,
tpe: HandlerType[I, O],
key: str,
arg: I,
send_delay: typing.Optional[timedelta] = None,
limit_key: str | None = None,
idempotency_key: str | None = None,
headers: typing.Dict[str, str] | None = None,
) -> RestateClientSendHandle:
"""
Make a send operation to the given object handler, within this scope.

NOTE: To use scopes with virtual objects you must enable the additional experimental feature in restate-server,
via RESTATE_EXPERIMENTAL_ENABLE_SCOPED_VIRTUAL_OBJECTS=true
"""
pass

@abc.abstractmethod
async def workflow_call(
self,
Expand Down
35 changes: 35 additions & 0 deletions python/restate/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,41 @@ def service_send(
Invokes the given service with the given argument, within this scope.
"""

@abc.abstractmethod
def object_call(
self,
tpe: HandlerType[I, O],
key: str,
arg: I,
limit_key: str | None = None,
idempotency_key: str | None = None,
headers: typing.Dict[str, str] | None = None,
) -> RestateDurableCallFuture[O]:
"""
Invokes the given object handler with the given argument, within this scope.

NOTE: To use scopes with virtual objects you must enable the additional experimental feature in restate-server,
via RESTATE_EXPERIMENTAL_ENABLE_SCOPED_VIRTUAL_OBJECTS=true
"""

@abc.abstractmethod
def object_send(
self,
tpe: HandlerType[I, O],
key: str,
arg: I,
send_delay: Optional[timedelta] = None,
limit_key: str | None = None,
idempotency_key: str | None = None,
headers: typing.Dict[str, str] | None = None,
) -> SendHandle:
"""
Invokes the given object handler with the given argument, within this scope.

NOTE: To use scopes with virtual objects you must enable the additional experimental feature in restate-server,
via RESTATE_EXPERIMENTAL_ENABLE_SCOPED_VIRTUAL_OBJECTS=true
"""

@abc.abstractmethod
def workflow_call(
self,
Expand Down
45 changes: 45 additions & 0 deletions python/restate/server_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,51 @@ def service_send(
assert isinstance(send, SendHandle)
return send

def object_call(
self,
tpe: HandlerType[I, O],
key: str,
arg: I,
limit_key: str | None = None,
idempotency_key: str | None = None,
headers: typing.Dict[str, str] | None = None,
) -> RestateDurableCallFuture[O]:
coro = self.context.do_call(
tpe,
arg,
key,
idempotency_key=idempotency_key,
headers=headers,
scope=self.scope,
limit_key=limit_key,
)
assert not isinstance(coro, SendHandle)
return coro

def object_send(
self,
tpe: HandlerType[I, O],
key: str,
arg: I,
send_delay: Optional[timedelta] = None,
limit_key: str | None = None,
idempotency_key: str | None = None,
headers: typing.Dict[str, str] | None = None,
) -> SendHandle:
send = self.context.do_call(
tpe=tpe,
key=key,
parameter=arg,
send_delay=send_delay,
send=True,
idempotency_key=idempotency_key,
headers=headers,
scope=self.scope,
limit_key=limit_key,
)
assert isinstance(send, SendHandle)
return send

def workflow_call(
self,
tpe: HandlerType[I, O],
Expand Down
Loading