cluster/stmt: Split registered statements by caller package#65
Conversation
If a microcluster project indirectly imports microcluster from another project (i.e. microcloud using microceph, which both use microcluster), then the map of registered statements may end up polluted with entries from that project. To avoid this, a call to microcluster.Start will record the name of the caller package (whether from snap build, GOPATH, or go module), and record it in the daemon. As well, on start, when calls to `RegisterStmt` are executed, those packages will be recorded, and statements will be registered by their package. Then, when preparing statements, only statements belonging to the daemon package, or to 'microcluster' (as that is ubiquitous) will be prepared. Signed-off-by: Max Asnaashari <max.asnaashari@canonical.com>
|
I'm confused as to why we need to specify the project in NewDaemon. Given we have the logic to extract the project from the file path at the time of adding the statements, we should be able to similarly extract the caller's project at the time of preparing them, no? |
The package found by It's also done in an API call, so we can't go backward a constant amount and expect to find |
|
Ah, right, that makes sense. |
If a microcluster project indirectly imports microcluster from another project (i.e. microcloud using microceph, which both use microcluster), then the map of registered statements may end up polluted with entries from that project.
To avoid this, a call to microcluster.Start will record the name of the caller package (whether from snap build, GOPATH, or go module), and record it in the daemon.
As well, on start, when calls to
RegisterStmtare executed, those packages will be recorded, and statements will be registered by their package.Then, when preparing statements, only statements belonging to the daemon package, or to 'microcluster' (as that is ubiquitous) will be prepared.