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

Consider: global task ID #5

Closed
Vectorial1024 opened this issue Dec 5, 2024 · 1 comment · Fixed by #14
Closed

Consider: global task ID #5

Vectorial1024 opened this issue Dec 5, 2024 · 1 comment · Fixed by #14
Labels
enhancement New feature or request question Further information is requested

Comments

@Vectorial1024
Copy link
Owner

Usually, tasks are started anonymously with no ID. But, since we have full creative control here, we can just allow users to choose that a task must have a global ID. This does not affect task execution, but what we can do is that, we can save the ID in e.g. the database, and then when we want to, we can just "recreate" the task from the ID and check whether it is still running.

A ULID would be a good random globally-unique ID. Or, the task can have a user-specified constant ID for singleton tasks (i.e. task can only be run with a single instance).

Think about whether this is a good idea.

@Vectorial1024 Vectorial1024 added enhancement New feature or request question Further information is requested labels Dec 5, 2024
@Vectorial1024
Copy link
Owner Author

Vectorial1024 commented Jan 4, 2025

After some thinking, I can think of the following:

  • Every task at least gets a ULID task ID; this enables the "put to background then recheck later" use case
  • User may specify a string task ID, which replaces the aforementioned ULID task ID
  • Task IDs are converted to base64 for coding convenience
  • With a task ID available, users may then create a special, simplified object that checks whether the task with the given ID is still running
  • We usually do not check for ID uniqueness; when checking whether a task is still running, we will simply return the first one we found
    • This is not a problem if we are using ULIDs
    • If users are using their specific task IDs, they have responsibility to make sure the task IDs are not clashing
    • Alternatively, we can set a toggle to make the task creation fail when it detects a task ID clash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant