feat: Add simpler API for creating external tasks#570
Conversation
While it was possible to create external tasks by creating a standalone registry, and using it to define tasks, these changes make creating external namespaces and tasks more ergonomic and provide conventions for routing tasks between applications. Refs STREAM-611
evanh
left a comment
There was a problem hiding this comment.
What is the scenario where an application would want to submit tasks for another application?
The upcoming scenario is from sentry -> launchpad. The sentry API receives uploads from customer build tooling. Sentry does authentication and request validation and then will spawn a task in launchpad. This will replace the kafka consumer in launchpad. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| """ | ||
| key = f"{application}:{name}" | ||
| if key in self._external_namespaces: | ||
| raise ValueError(f"External task namespace with name {name} already exists.") |
There was a problem hiding this comment.
Duplicate error message omits application context
Low Severity
The duplicate-check in create_external_namespace uses the composite key f"{application}:{name}" but the error message only includes {name}, not {application}. This makes the error misleading — it implies the collision is on the name alone, when it's actually on the application:name pair. The sibling method get_external correctly includes both application and name in its error message.
| self._registered_tasks[name] = task | ||
| return task | ||
|
|
||
| return wrapped |
There was a problem hiding this comment.
Duplicated register logic across namespace classes
Low Severity
ExternalNamespace.register is a near-identical copy of TaskNamespace.register — the only difference is instantiating ExternalTask instead of Task. The retry-handling logic, default-resolution, and task-storage code are fully duplicated, meaning any future bug fix or behavior change needs to be applied in both places.


While it was possible to create external tasks by creating a standalone registry, and using it to define tasks, these changes make creating external namespaces and tasks more ergonomic and provide conventions for routing tasks between applications.
Refs STREAM-611