Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Aug 2, 2023
1 parent 3d97c9b commit 7239a34
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Options:
--port <int> The process will listen on this port for any HTTP and Prometheus metrics requests (default: 9102, env: PORT)
--metrics-labels [string...] To apply generic labels to all default metrics (ex: --labels foo=bar) (default: {}, env: METRICS_LABELS)
--collect-default-metrics <boolean> Collect default metrics (default: false, env: COLLECT_DEFAULT_METRICS)
--headers [string...] Set headers that will be sent on every requests (ex: --headers X-HEADER=headerA) (default: [], env: HEADERS)
--verbose Enable verbose logging (default: false, env: VERBOSE)
-h, --help display help for command
```
Expand All @@ -62,18 +63,19 @@ Options:
```js
import pkg from "./package.json" assert { type: "json" };
import { commander, setup, prometheus, http } from "substreams-sink";
import { commander, setup, prometheus, http, logger } from "substreams-sink";

// Setup CLI using Commander
const program = commander.program(pkg);
const command = commander.run(program, pkg);
logger.setName(pkg.name);

// Custom Prometheus Counters
const customCounter = prometheus.registerCounter("custom_counter");

command.action(async (options: commander.RunOptions) => {
// Setup sink for Block Emitter
const {emitter} = await setup(options, pkg);
const {emitter} = await setup(options);

// Stream Blocks
emitter.on("anyMessage", (message, cursor, clock) => {
Expand All @@ -87,6 +89,8 @@ command.action(async (options: commander.RunOptions) => {
http.listen(options);

// Start streaming
emitter.start();
await emitter.start();
http.server.close();
})
program.parse();
```

0 comments on commit 7239a34

Please sign in to comment.