-
Notifications
You must be signed in to change notification settings - Fork 31
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
Support for multiple dbos app files in NextJs App #700
base: main
Are you sure you want to change the base?
Changes from all commits
bfd8280
58f4182
bceb29b
3fa8eea
063002d
ef83ccc
ec16446
8f0bd72
a7ec63e
0449b3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,9 +147,27 @@ export class DBOS { | |
set(conf, key, newValue); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
static async register(cls: any) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do this and launch relate? Does launch do things that this doesn't? When do you need both or just one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Register registers one class. Launch intializes various things in the runtime like http, loggers, db connections etc. It does have some registration code that needs to be refactored out imho. Launch needs to be called only once. Register needs to be called once per file. Register calls launch because someone has to call launch but launch wll run only once There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it! And is it okay if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Because we explicitly register again |
||
|
||
await this.launch(); | ||
|
||
const executor = DBOSExecutor.globalInstance; | ||
|
||
if (executor !== undefined) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access | ||
executor.registerClass(cls.name) | ||
} else { | ||
throw new DBOSExecutorNotInitializedError(); | ||
} | ||
|
||
} | ||
|
||
static async launch(httpApps?: DBOSHttpApps) { | ||
// Do nothing is DBOS is already initialized | ||
if (DBOSExecutor.globalInstance) return; | ||
if (DBOSExecutor.globalInstance) { | ||
return | ||
} | ||
|
||
// Initialize the DBOS executor | ||
if (!DBOS.dbosConfig) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no longer any need for
DBOS.launch()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in NextJs. register calls launch.
But we do need to run the launch method once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is having classes registered after launch. This is guaranteed to not be 100% working at the moment...