temporalio / sdk-typescript

Temporal TypeScript SDK
Other
532 stars 105 forks source link

[Feature Request] Session support #388

Open schickling opened 2 years ago

schickling commented 2 years ago

Would be great if Sessions similar to the Go SDK were supported in TS as well.

lorensr commented 2 years ago

Here's an alternative:

https://github.com/temporalio/samples-typescript/tree/main/activities-sticky-queues

If anyone has a use case in which this doesn't work well, please post a comment, thanks!

bergundy commented 2 years ago

Note that the main difference between sticky activities and sessions is concurrency control, max concurrent sessions vs to max concurrent activities per worker.

morgante commented 1 year ago

I took a look at the sticky queue but it's not clear that it matches exactly what I need. In particular, I have two doubts/questions:

  1. I want the worker to be able to listen on multiple queues. The workflow should only be coupled to a particular worker after it has picked up the first task.
  2. If the worker crashes midway through execution, how do I ensure the next worker that spawns for that workflow will start over from the beginning?
bergundy commented 1 year ago

Sorry for the late response.

  1. I want the worker to be able to listen on multiple queues. The workflow should only be coupled to a particular worker after it has picked up the first task.

A worker only listens on a single task queue but you can start multiple workers in the same process. Coupling the workflow to a worker is shown in the sample posted above.

  1. If the worker crashes midway through execution, how do I ensure the next worker that spawns for that workflow will start over from the beginning?

You'll need to use schedule to start timeout to detect that the worker went away and restart the sequence of activities. This is all part of the sticky activity queues sample.