Make sure Sandy plugis can be initialized
Summary:
This diff makes sure sandy plugins are initialized.
Sandy plugins are stored directly in the client for two reasons
1. we want to decouple any plugin state updates from our central redux store, as redux is particularly bad in handling high frequency updates.
2. The lifecycle of a plugin is now bound to the lifecycle of a client. This means that we don't need 'persistedStore' to make sure state is preserved; that is now the default. Switching plugins will no longer reinitialize them (but only run specific hooks, see later diffs).
3. PersistedState will be introduced for sandy plugins as well later, but primarily for import / export / debug reasons.
A significant difference with the current persistent state, is that if a client crashes and reconnects, plugins will loose their state. We can prevent this (again, since state persisting will be reintroduced), but I'm not sure we need that for the specific reconnect scenario. Because
1. we should fix reconnecting clients anyway, and from stats it looks to happen less already
2. reconnects are usually caused by plugins that aggregate a lot of data and get slower over time. Restoring old state also restores those unstabilites.
For the overview bringing back the archi picture of earlier diff:
{F241508042}
Also fixed a bug where enabling background plugins didn't enable them on all devices with that app.
Reviewed By: jknoxville
Differential Revision: D22186276
fbshipit-source-id: 3fd42b577f86920e5280aa8cce1a0bc4d5564ed9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bf79c9472e
commit
1dc9e899b8
@@ -57,7 +57,7 @@ class TestPlugin extends FlipperPlugin<any, any, any> {
|
||||
function starTestPlugin(store: Store, client: Client) {
|
||||
store.dispatch(
|
||||
starPlugin({
|
||||
selectedPlugin: TestPlugin.id,
|
||||
plugin: TestPlugin,
|
||||
selectedApp: client.query.app,
|
||||
}),
|
||||
);
|
||||
@@ -214,7 +214,7 @@ test('queue - events are queued for plugins that are favorite when app is not se
|
||||
selectDeviceLogs(store);
|
||||
expect(store.getState().connections.selectedPlugin).not.toBe('TestPlugin');
|
||||
|
||||
const client2 = createClient(device, 'TestApp2');
|
||||
const client2 = await createClient(device, 'TestApp2');
|
||||
store.dispatch(selectClient(client2.id));
|
||||
|
||||
// Now we send a message to the second client, it should arrive,
|
||||
@@ -248,27 +248,39 @@ test('queue - events are queued for plugins that are favorite when app is select
|
||||
expect(store.getState().connections.selectedPlugin).not.toBe('TestPlugin');
|
||||
|
||||
const device2 = createDevice('serial2');
|
||||
const client2 = createClient(device2, client.query.app); // same app id
|
||||
const client2 = await createClient(device2, client.query.app); // same app id
|
||||
store.dispatch(selectDevice(device2));
|
||||
store.dispatch(selectClient(client2.id));
|
||||
|
||||
// Now we send a message to the second client, it should arrive,
|
||||
// Now we send a message to the first and second client, it should arrive,
|
||||
// as the plugin was enabled already on the first client as well
|
||||
sendMessage('inc', {delta: 2});
|
||||
sendMessage('inc', {delta: 3}, client2);
|
||||
client.flushMessageBuffer();
|
||||
client2.flushMessageBuffer();
|
||||
expect(store.getState().pluginStates).toMatchInlineSnapshot(`Object {}`);
|
||||
expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"TestApp#Android#MockAndroidDevice#serial#TestPlugin": Array [
|
||||
Object {
|
||||
"api": "TestPlugin",
|
||||
"method": "inc",
|
||||
"params": Object {
|
||||
"delta": 2,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"TestApp#Android#MockAndroidDevice#serial#TestPlugin": Array [
|
||||
Object {
|
||||
"api": "TestPlugin",
|
||||
"method": "inc",
|
||||
"params": Object {
|
||||
"delta": 2,
|
||||
},
|
||||
},
|
||||
],
|
||||
"TestApp#Android#MockAndroidDevice#serial2#TestPlugin": Array [
|
||||
Object {
|
||||
"api": "TestPlugin",
|
||||
"method": "inc",
|
||||
"params": Object {
|
||||
"delta": 3,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('queue - events processing will be paused', async () => {
|
||||
|
||||
Reference in New Issue
Block a user