Progress
-
Deciding the file structure and import schema.
As for now, decided to create aMonitor
class for creating a monitor object that is responsible for storing plugin metadata and persisting usage metrics between consecutive electron API calls. More is discussed about the class members in subsequent points.packages │ . └───app-desktop │ │ │ └───services │ │ │ │ │ └───plugins │ │ │ │ │ │ │ └───resource-monitor │ │ │ │ │ `Monitor.ts` │ │ │ │ │ `runner.ts`
-
The Monitor class is scaffolded as follows now:
export class Monitor { private _pluginStore: PluginDetails[]; constructor() { this._pluginStore = [x]; } addPlugin(osPId: number, plugin: any) { this._pluginStore.push({osPId, plugin}); } getPlugin(osId: number) { return this._pluginStore.find(p => p.osPId === osId); } get pluginStore() { return this._pluginStore; } }
-
The usage metrics is fetched using the
ElectronApp.getAppMetrics()
method. Reference
It is then paired with the plugin metadata from theplugin
object that is passed intorun()
function inPluginRunner.ts
.
Thus, a completePluginDetails
object is formed, and appended to_pluginStore
each time a new plugin is started using therun()
method.
Plans
-
Updating
_pluginStore
using a member function, this involves:- Fetching latest resource usage from the Electron API.
- Checking for removed or newly added plugins and updating accordingly.
-
Accessing the
Monitor
object created inrunner.ts
in the GUI of the electron app, and displaying updated information.
Problems
- I could not figure out how to make my test plugin use a certain (relatively large) amount of memory for a long time, as any unused variable is likely being deallocated by the garbage collector.
I tried to loop over a large array of strings to prevent this, however, infinite looping eventually crashes my device by using too much CPU.