Update codegen to add subgraph source to watcher readme (#514)

* Update codegen to add subgraph source to watcher readme

* Update exported metrics for watcher config

* Add steps to update package json and config to codegen instructions

---------

Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
Nabarun Gogoi 2024-06-11 14:42:54 +05:30 committed by GitHub
parent acf69dd554
commit 7884941e75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 28 additions and 3 deletions

View File

@ -114,6 +114,10 @@ Steps:
This will create a folder containing the generated code at the path provided in config. Follow the steps in [Run Generated Watcher](#run-generated-watcher) to setup and run the generated watcher.
* Update generated watcher's `package.json` with desired `version`, `description`, `repository` URL, etc.
* Update generated watcher's config (`environments/local.toml`) as required
## Development
* `lint`

View File

@ -265,7 +265,7 @@ function generateWatcher (visitor: Visitor, contracts: any[], config: any, overW
outStream = outputDir
? fs.createWriteStream(path.join(outputDir, 'README.md'))
: process.stdout;
exportReadme(path.basename(outputDir), config.port, outStream);
exportReadme(path.basename(outputDir), config, outStream);
outStream = outputDir
? fs.createWriteStream(path.join(outputDir, 'LICENSE'))

View File

@ -15,12 +15,25 @@ const TEMPLATE_FILE = './templates/readme-template.handlebars';
* @param port Watcher server port.
* @param outStream A writable output stream to write the README.md file to.
*/
export function exportReadme (folderName: string, port: number, outStream: Writable): void {
export function exportReadme (
folderName: string,
config: { port: number, subgraphPath?: string },
outStream: Writable
): void {
const { port, subgraphPath } = config;
const templateString = fs.readFileSync(path.resolve(__dirname, TEMPLATE_FILE)).toString();
const template = Handlebars.compile(templateString);
let subgraphRepoName;
if (subgraphPath) {
const subgraphRepoDir = path.dirname(subgraphPath);
subgraphRepoName = path.basename(subgraphRepoDir);
}
const readmeString = template({
folderName,
port
port,
subgraphRepoName
});
outStream.write(readmeString);
}

View File

@ -1,5 +1,12 @@
# {{folderName}}
{{#if (subgraphPath)}}
## Source
<!-- TODO: Update with publised subgraph release version -->
* Subgraph: [{{subgraphRepoName}} v0.1.0](https://github.com/cerc-io/{{subgraphRepoName}}/releases/tag/v0.1.0)
{{/if}}
## Setup
* Run the following command to install required packages:

View File

@ -245,6 +245,7 @@ const registerWatcherConfigMetrics = async ({ server, upstream, jobQueue }: Conf
watcherConfigMetric.set({ category: 'jobqueue', field: 'num_events_in_batch' }, Number(jobQueue.eventsInBatch));
watcherConfigMetric.set({ category: 'jobqueue', field: 'block_delay_seconds' }, (Number(jobQueue.blockDelayInMilliSecs) || 0) / 1000);
watcherConfigMetric.set({ category: 'jobqueue', field: 'block_processing_offset' }, Number(jobQueue.blockProcessingOffset) ?? 0);
watcherConfigMetric.set({ category: 'jobqueue', field: 'use_block_ranges' }, Number(jobQueue.useBlockRanges));
watcherConfigMetric.set({ category: 'jobqueue', field: 'historical_logs_block_range' }, Number(jobQueue.historicalLogsBlockRange));
watcherConfigMetric.set({ category: 'jobqueue', field: 'historical_max_fetch_ahead' }, Number(jobQueue.historicalMaxFetchAhead));