You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to use Temporal in our systems, we need the ability to inject dependencies such as grpc connections, db connections, kafka connections, auth data into temporal workflows and activities, using pinject, that are scoped at different levels (global, customer specific).
Here's an example:
Say you have a python class to fetch customer scoped data from redis:
from pinject import new_object_graph
import redis
class CustomerDataAccess:
def __init__(self, customer_partition):
# this is simplified. IRL there would be nested dependencies injected
self.customer_partition = customer_partition
self.redis_client = redis.Redis()
def get_data(self):
# Access data from the specified customer partition in Redis
data = self.redis_client.get(self.customer_partition)
return data
and then you have a workflow and an activity that needs this dependency:
# Define the Workflow interface
class CustomerWorkflow:
@workflow_method(task_queue="customer-data")
def get_customer_data(self) -> str:
pass
# Implement the Workflow
class CustomerWorkflowImpl(CustomerWorkflow):
def __init__(self, customer_data_access: CustomerDataAccess):
self.data_access = customer_data_access
def get_customer_data(self) -> str:
# Access data from a specific customer partition using the Activity
data = self.data_access.get_data("customer1")
# do business logic on this data
return result
Describe the solution you'd like
Proposed solution: Add support for pinject, similar to how you folks added support for Spring Boot in Java: temporalio/sdk-java#745
Additional context
The text was updated successfully, but these errors were encountered:
In order to use Temporal in our systems, we need the ability to inject dependencies such as grpc connections, db connections, kafka connections, auth data into temporal workflows and activities, using pinject, that are scoped at different levels (global, customer specific).
Here's an example:
Say you have a python class to fetch customer scoped data from redis:
and then you have a workflow and an activity that needs this dependency:
Describe the solution you'd like
Proposed solution: Add support for pinject, similar to how you folks added support for Spring Boot in Java: temporalio/sdk-java#745
Additional context
The text was updated successfully, but these errors were encountered: