Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sdk core related updates #191

Merged
merged 8 commits into from
Nov 10, 2022
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
17 changes: 10 additions & 7 deletions temporalio/bridge/Cargo.lock

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

4 changes: 3 additions & 1 deletion temporalio/bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ crate-type = ["cdylib"]

[dependencies]
log = "0.4"
once_cell = "1.16.0"
parking_lot = "0.12"
prost = "0.11"
prost-types = "0.11"
Expand All @@ -21,10 +22,11 @@ temporal-sdk-core-protos = { version = "0.1.0", path = "./sdk-core/sdk-core-prot
tokio = "1.15"
tokio-stream = "0.1"
tonic = "0.8"
tracing = "0.1"
url = "2.2"

[profile.release]
opt-level = 3
debug = false
lto = true
incremental = false
incremental = false
21 changes: 18 additions & 3 deletions temporalio/bridge/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import google.protobuf.message

import temporalio.bridge.runtime
import temporalio.bridge.temporal_sdk_bridge
from temporalio.bridge.temporal_sdk_bridge import RPCError

Expand Down Expand Up @@ -68,16 +69,30 @@ class Client:
"""RPC client using SDK Core."""

@staticmethod
async def connect(config: ClientConfig) -> Client:
async def connect(
runtime: temporalio.bridge.runtime.Runtime, config: ClientConfig
) -> Client:
"""Establish connection with server."""
return Client(
await temporalio.bridge.temporal_sdk_bridge.connect_client(config)
runtime,
await temporalio.bridge.temporal_sdk_bridge.connect_client(
runtime._ref, config
),
)

def __init__(self, ref: temporalio.bridge.temporal_sdk_bridge.ClientRef):
def __init__(
self,
runtime: temporalio.bridge.runtime.Runtime,
ref: temporalio.bridge.temporal_sdk_bridge.ClientRef,
):
"""Initialize client with underlying SDK Core reference."""
self._runtime = runtime
self._ref = ref

def update_metadata(self, metadata: Mapping[str, str]) -> None:
"""Update underlying metadata on Core client."""
self._ref.update_metadata(metadata)

async def call(
self,
*,
Expand Down
2 changes: 2 additions & 0 deletions temporalio/bridge/proto/workflow_commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
CompleteWorkflowExecution,
ContinueAsNewWorkflowExecution,
FailWorkflowExecution,
ModifyWorkflowProperties,
QueryResult,
QuerySuccess,
RequestCancelActivity,
Expand All @@ -31,6 +32,7 @@
"CompleteWorkflowExecution",
"ContinueAsNewWorkflowExecution",
"FailWorkflowExecution",
"ModifyWorkflowProperties",
"QueryResult",
"QuerySuccess",
"RequestCancelActivity",
Expand Down
126 changes: 64 additions & 62 deletions temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class WorkflowCommand(google.protobuf.message.Message):
SCHEDULE_LOCAL_ACTIVITY_FIELD_NUMBER: builtins.int
REQUEST_CANCEL_LOCAL_ACTIVITY_FIELD_NUMBER: builtins.int
UPSERT_WORKFLOW_SEARCH_ATTRIBUTES_FIELD_NUMBER: builtins.int
MODIFY_WORKFLOW_PROPERTIES_FIELD_NUMBER: builtins.int
@property
def start_timer(self) -> global___StartTimer: ...
@property
Expand Down Expand Up @@ -138,6 +139,8 @@ class WorkflowCommand(google.protobuf.message.Message):
def upsert_workflow_search_attributes(
self,
) -> global___UpsertWorkflowSearchAttributes: ...
@property
def modify_workflow_properties(self) -> global___ModifyWorkflowProperties: ...
def __init__(
self,
*,
Expand Down Expand Up @@ -165,6 +168,7 @@ class WorkflowCommand(google.protobuf.message.Message):
request_cancel_local_activity: global___RequestCancelLocalActivity | None = ...,
upsert_workflow_search_attributes: global___UpsertWorkflowSearchAttributes
| None = ...,
modify_workflow_properties: global___ModifyWorkflowProperties | None = ...,
) -> None: ...
def HasField(
self,
Expand All @@ -183,6 +187,8 @@ class WorkflowCommand(google.protobuf.message.Message):
b"continue_as_new_workflow_execution",
"fail_workflow_execution",
b"fail_workflow_execution",
"modify_workflow_properties",
b"modify_workflow_properties",
"request_cancel_activity",
b"request_cancel_activity",
"request_cancel_external_workflow_execution",
Expand Down Expand Up @@ -226,6 +232,8 @@ class WorkflowCommand(google.protobuf.message.Message):
b"continue_as_new_workflow_execution",
"fail_workflow_execution",
b"fail_workflow_execution",
"modify_workflow_properties",
b"modify_workflow_properties",
"request_cancel_activity",
b"request_cancel_activity",
"request_cancel_external_workflow_execution",
Expand Down Expand Up @@ -273,6 +281,7 @@ class WorkflowCommand(google.protobuf.message.Message):
"schedule_local_activity",
"request_cancel_local_activity",
"upsert_workflow_search_attributes",
"modify_workflow_properties",
] | None: ...

global___WorkflowCommand = WorkflowCommand
Expand Down Expand Up @@ -352,7 +361,6 @@ class ScheduleActivity(google.protobuf.message.Message):
SEQ_FIELD_NUMBER: builtins.int
ACTIVITY_ID_FIELD_NUMBER: builtins.int
ACTIVITY_TYPE_FIELD_NUMBER: builtins.int
NAMESPACE_FIELD_NUMBER: builtins.int
TASK_QUEUE_FIELD_NUMBER: builtins.int
HEADERS_FIELD_NUMBER: builtins.int
ARGUMENTS_FIELD_NUMBER: builtins.int
Expand All @@ -367,7 +375,6 @@ class ScheduleActivity(google.protobuf.message.Message):
"""/ Lang's incremental sequence number, used as the operation identifier"""
activity_id: builtins.str
activity_type: builtins.str
namespace: builtins.str
task_queue: builtins.str
"""The name of the task queue to place this activity request in"""
@property
Expand Down Expand Up @@ -422,7 +429,6 @@ class ScheduleActivity(google.protobuf.message.Message):
seq: builtins.int = ...,
activity_id: builtins.str = ...,
activity_type: builtins.str = ...,
namespace: builtins.str = ...,
task_queue: builtins.str = ...,
headers: collections.abc.Mapping[
builtins.str, temporalio.api.common.v1.message_pb2.Payload
Expand Down Expand Up @@ -472,8 +478,6 @@ class ScheduleActivity(google.protobuf.message.Message):
b"headers",
"heartbeat_timeout",
b"heartbeat_timeout",
"namespace",
b"namespace",
"retry_policy",
b"retry_policy",
"schedule_to_close_timeout",
Expand Down Expand Up @@ -1531,3 +1535,27 @@ class UpsertWorkflowSearchAttributes(google.protobuf.message.Message):
) -> None: ...

global___UpsertWorkflowSearchAttributes = UpsertWorkflowSearchAttributes

class ModifyWorkflowProperties(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

UPSERTED_MEMO_FIELD_NUMBER: builtins.int
@property
def upserted_memo(self) -> temporalio.api.common.v1.message_pb2.Memo:
"""If set, update the workflow memo with the provided values. The values will be merged with
the existing memo. If the user wants to delete values, a default/empty Payload should be
used as the value for the key being deleted.
"""
def __init__(
self,
*,
upserted_memo: temporalio.api.common.v1.message_pb2.Memo | None = ...,
) -> None: ...
def HasField(
self, field_name: typing_extensions.Literal["upserted_memo", b"upserted_memo"]
) -> builtins.bool: ...
def ClearField(
self, field_name: typing_extensions.Literal["upserted_memo", b"upserted_memo"]
) -> None: ...

global___ModifyWorkflowProperties = ModifyWorkflowProperties
Loading