dhiaayachi / temporal

Temporal service
https://docs.temporal.io
MIT License
0 stars 0 forks source link

access from one temporal namespace to another #209

Open dhiaayachi opened 2 months ago

dhiaayachi commented 2 months ago

hello, I was wondering if there any additional considerations when referencing resources from one namespace to another?

For instance: lets say I workflow_1 that contains activity_1 and resides in temporal namespace_1 and I also have namespace_2 which contains workflow_2 and activity_2 and both temporal namespaces, namespace_1 and namespace_2, exist in the same temporal server

would we run into any issues if the inputs for activity_2 depends on outputs from activity_1? I'm not sure if temporal namespaces behave like k8s namespaces as far as access

dhiaayachi commented 2 months ago

Thanks for reporting this question!

Temporal Namespaces do not behave like Kubernetes Namespaces, where the resources of one Namespace are not accessible to another.

Temporal Namespaces primarily function as organizational units, allowing you to group related Workflows and Activities.

However, Temporal relies on a shared global state to manage its operations. The underlying persistence layer is shared across all Namespaces within a Temporal Cluster. This means that if activity_2 depends on outputs from activity_1, you will need to ensure that:

To ensure data flow, you will need to handle data dependencies explicitly. This can involve using:

Temporal offers various mechanisms for managing data flow and communication between Workflows and Activities. The best approach will depend on your specific requirements and application architecture.

Remember to consider factors like data consistency, latency, and the level of isolation needed when deciding how to handle data dependencies between activities across Namespaces.

dhiaayachi commented 2 months ago

Thanks for your question! Temporal namespaces do not behave exactly like Kubernetes namespaces. You can reference resources between namespaces, but you need to be aware of a few things.

The namespaces in Temporal are isolated by default, and the way they are isolated is more akin to separate Temporal clusters. That means a workflow in one namespace cannot directly access data or invoke activities in another namespace.

You can achieve the functionality you are looking for with the following methods:

  1. Using a shared namespace: You can put both workflow_1 and workflow_2 in the same namespace. This allows you to directly access resources from one workflow to the other.
  2. Using signals: You can send signals from workflow_1 to workflow_2 to share information. The signal needs to be defined in both workflows, and the workflow_2 needs to handle the signal to react to it and update its internal state.

While Temporal namespaces do not behave exactly like Kubernetes namespaces, they are a powerful mechanism for isolation and organization within the Temporal platform. If you have additional questions, please feel free to ask.

dhiaayachi commented 2 months ago

Thanks for reporting this question! Temporal Namespaces do not behave like Kubernetes namespaces in terms of access control. Temporal namespaces are intended to isolate workflows at an application level. If workflow_1 needs to interact with activity_2, you can either:

Let us know if you have any other questions!

dhiaayachi commented 2 months ago

Thanks for reporting this! Temporal Namespaces do not currently allow inter-namespace communication. The temporal CLI can be used to manage different Namespaces. You can look into the following documentation to learn more about how to manage Namespaces with temporal.

If you'd like to explore a more modular architecture for your application, you can look into Temporal Nexus. Nexus enables cross-namespace communication through well-defined API contracts.