npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@chainlink/gauntlet-core

v1.5.1

Published

TODO: Explain the package and its components: Operations, Client, Dependencies, Operation Runner, etc.

Downloads

26,408

Readme

Gauntlet Core

TODO: Explain the package and its components: Operations, Client, Dependencies, Operation Runner, etc.

Interceptors

Interceptors are used to extract and treat information that goes through the Gauntlet Client.

The Gauntlet Client expects an optional interceptors parameter, which is an optional list of implementations of the ClientInterceptor interface. As ClientInterceptor intercepts Gauntlet Client calls, is expected that the interface has similarities with the Gauntlet Client interface.

export interface ClientInterceptor {
  execute: (input: InterceptorExecuteInput, next: Next<this, 'execute'>) => Promise<Report>

  plan: (input: InterceptorPlanInput, next: Next<this, 'plan'>) => Promise<Report>

  query: (input: InterceptorQueryInput, next: Next<this, 'query'>) => Promise<Report>
}

A simple implementation could just be for logging purposes:

export class LoggerClientInterceptor implements ClientInterceptor {
  readonly log: Logger

  constructor(logger: Logger) {
    this.log = logger
  }

  async execute(
    input: InterceptorExecuteInput,
    next: Next<ClientInterceptor, 'execute'>,
  ): Promise<ReportAny> {
    this.log.info(`Execution starting with plan: ${JSON.stringify(input.plan)}`)
    const report = await next(input)
    this.log.info(`Execution finished with report: ${JSON.stringify(report)}`)
    return report
  }

  async plan(
    input: InterceptorPlanInput,
    next: Next<ClientInterceptor, 'plan'>,
  ): Promise<ReportAny> {
    this.log.info(`Command plan stage starting with input: ${JSON.stringify(input.input)}`)
    const report = await next(input)
    this.log.info(`Plan stage finished with report: ${JSON.stringify(report)}`)
    return report
  }

  // ...
}

The user can enable many Interceptors in the client by just providing implementations of ClientInterceptor

;(async () => {
  // We configure the interceptors at building time in the client
  const client = buildClient(packages, factories, [
    new LoggerClientInterceptor(),
    new TracingInterceptor(),
  ])

  const report = client.plan(op.def, input, config, traceExtra) // we can expect this execution to have both logging and tracing interceptions
})()

Operations

TODO!

RuntimeContext

TODO!

Ctx.Emit

The ctx.emit function allows developers to add custom events with associated data when planning an operation, which can then be aggregated or reported in a structured format.

Using ctx.emit

The ctx.emit function is defined as follows:

emit: (msg: string, payload?: EventPayload) => void
Parameters
  • msg: A string message describing the event.
  • payload: An optional parameter that includes the type and properties defining the event.
Examples
  1. Emitting a Diff Event

    When there's a change in state that needs to be captured:

    ctx.emit('Would add a new owner to the safe', asDiffEvent(prev, head))
  2. Emitting a Generic Event

    For less structured events:

    ctx.emit('Any event', { type: 'any', object: 5, a: { c: 2 } })
  3. Emitting Without Payload

    Simply sending a message without additional data:

    ctx.emit('without payload')