Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP: the quickjs comparison bit is not implemented yet] The app scans all the dbs and docs. It has a plugin system to allow gathering various things from a cluster. The first use is to scan all the javascript design docs and run them through the new QuickJS javascript engine. Other possible uses: - Detect features used in design docs - Gather total db and view sizes - Scan for document features (docs of certain sizes, contained certain fields and values). - Scan replication dbs/doc features The plugins are managed as invididual process by the couch_scanner_server with the start_link/1 and stop/1 functions. After a plugin runner is spawned, the only thing couch_scanner_server does is wait for it to exit. The plugin runner process may exit normally, crash, or exit with `{shutdown, {reschedule, TSec}}` reason if they want to reschedule to run again at some point the future (next day, a week later, etc). After the process starts, it will load and validate the plugin module. Then, it will start scanning all the dbs, shards, ddocs and docs on the local node. Shard ranges will be scanned only on one of the cluster nodes to avoid duplicating work. For instance, if there are 2 shard ranges 0-7, 8-f on nodes n1, n2, n3. Then 0-7 might be scanned on n1 only, and 8-f on n3. The plugin API is the following: start(undefined | #{}) -> {ok, St} | {reschedule, TSec} stop(St) -> ok | {reschedule, TSec} checkpoint(St) -> {ok, #{}} db(St, DbName) -> {ok|skip|stop, St} ddoc(St, DbName, #{} = DDoc) -> {ok|skip|stop, St} shard(St, #shard{} = Shard) -> {ok|skip, St} doc_id(St, DocId, DocIndex, DocTotal, Db) -> {ok|skip|stop, St} doc(St, Db, DDocs, #{} = Doc) -> {ok|stop, St}
- Loading branch information