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

feat(migration): adjust BackendProcess, main.dev.js & App.ts so we can coordinate migrations! #571

Merged
merged 5 commits into from
Jul 16, 2020

Conversation

ramfox
Copy link
Member

@ramfox ramfox commented Jul 16, 2020

closes #566

My journey through this process has been decently well chronicled in the above issue!

My last comment would be, very open to re-structuring BackendProcess to take a window so that the main function is less unwieldy and is less responsible for coordinating the behavior. However, it might be nice to keep all the emitted events in the main.development.js file, so that behavior isn't hidden down in another class. Anyone have strong opinions?

Edit:
Backend is getting a refactor! Now commands won't "auto-trigger" a migration, unless you have the --migrations flag. And a command will fail w/ an exit error (2) if the config needs a migration. We can use these to remove the desktop's reliance on knowing about the QRI_PATH and keeping track of config revisions!

…d launch

We refactor the `BackendProcess` class to have specific methods that the main process can use to orchestrate launching the backend app
Because we can only emit events to the renderer process in the main process (so no way to emit them in `BackendProcess`, unless we pass the `mainWindow` down to the `BackendProcess` class) this exposes a bunch of launching functionality to the main process (it was previously all hidden in the `backendProcess.maybeStartup()` function)

In future refactors, am definitely open to pushing `mainWindow` down to `BackendProcess` and dealing with all aspects down there. However, as a first iteration I think this is fine.

The logic for this the start up goes like this:
- if a backend process is already running, error. Catch the error & send a message to the renderer that a qri backend is already running
- check if we have a compatible backend version. If it's too low, send a message to the renderer that the version is incompatible
- check if we need a migration - if we do, send a message to the renderer that we are migrating
- launch the backend
- add `BootupComponentType`
- `state.ui.bootupComponet` defaults to 'loading'
- add `UI_SET_BOOTUP_COMPONENT` action type
- add `setBootstrapComponent` action
- add `selectBootstrapComponent` selector
Both the renderer process and main process need to be on before we can successfully coordinate behavior.

`App` component now emits an `app-fully-loaded` event.

Moved the backend launching process into the ipcMain `app-fully-loaded` event handler. This also means that whenever the app re-loads, we check for a backend connection, and if we don't find one we launch again. Which I think is a nice pick up!

Downside is we get slightly longer loading time in dev mode (since it takes a bit to compile the app), but no discernible changes in prod mode!
@ramfox ramfox added the feat label Jul 16, 2020
@ramfox ramfox added this to the v0.4.3 milestone Jul 16, 2020
@ramfox ramfox self-assigned this Jul 16, 2020
@ramfox ramfox requested a review from b5 July 16, 2020 01:55
now that the backend flags/expectations have changed, we can run any comand to see if it exits with code `2` (which indicates that a migration is needed)
Copy link
Member

@b5 b5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brilliant. Some small fixes, but LGTM!

app/backend.js Outdated Show resolved Hide resolved
app/backend.js Outdated Show resolved Hide resolved
app/backend.js Outdated Show resolved Hide resolved
app/backend.js Outdated Show resolved Hide resolved
@ramfox ramfox merged commit 41cf068 into master Jul 16, 2020
@ramfox ramfox deleted the refactor_migration branch July 16, 2020 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(migrate): have desktop coordinate backend migrations needed to get desktop app to work
2 participants