@libp2p/interface
Advanced tools
Comparing version 2.3.0-127abe24b to 2.3.0-20d9ba73e
@@ -1,2 +0,2 @@ | ||
import type { AbortOptions, RoutingOptions } from '../index.js'; | ||
import type { RoutingOptions } from '../index.js'; | ||
import type { PeerInfo } from '../peer-info/index.js'; | ||
@@ -49,3 +49,3 @@ import type { CID } from 'multiformats/cid'; | ||
*/ | ||
cancelReprovide(key: CID, options?: AbortOptions): Promise<void>; | ||
cancelReprovide(key: CID, options?: RoutingOptions): Promise<void>; | ||
/** | ||
@@ -52,0 +52,0 @@ * Find the providers of the passed CID. |
@@ -676,2 +676,10 @@ /** | ||
/** | ||
* An object that includes a trace object that is passed onwards. | ||
* | ||
* This is used by metrics method tracing to link function calls together. | ||
*/ | ||
export interface TraceOptions { | ||
trace?: any; | ||
} | ||
/** | ||
* When a routing operation involves reading values, these options allow | ||
@@ -682,3 +690,3 @@ * controlling where the values are read from. By default libp2p will check | ||
*/ | ||
export interface RoutingOptions extends AbortOptions, ProgressOptions { | ||
export interface RoutingOptions extends AbortOptions, ProgressOptions, TraceOptions { | ||
/** | ||
@@ -685,0 +693,0 @@ * Pass `false` to not use the network |
@@ -444,3 +444,53 @@ import type { MultiaddrConnection, Stream, Connection } from '../connection/index.js'; | ||
registerSummaryGroup: ((name: string, options?: SummaryOptions) => SummaryGroup) & ((name: string, options: CalculatedSummaryOptions<Record<string, number>>) => void); | ||
/** | ||
* Wrap a function for tracing purposes. | ||
* | ||
* All functions wrapped like this should accept a final optional options arg. | ||
* | ||
* In order to pass an execution context along to create a multi-layered | ||
* trace, the index of the options arg must be specified. | ||
*/ | ||
traceFunction<F extends (...args: any[]) => AsyncIterator<any>>(name: string, fn: F, options?: TraceGeneratorFunctionOptions<Parameters<F>, ReturnType<F>, YieldType<ReturnType<F>>>): F; | ||
traceFunction<F extends (...args: any[]) => Iterator<any>>(name: string, fn: F, options?: TraceGeneratorFunctionOptions<Parameters<F>, ReturnType<F>, YieldType<ReturnType<F>>>): F; | ||
traceFunction<F extends (...args: any[]) => any = (...args: any[]) => any>(name: string, fn: F, options?: TraceFunctionOptions<Parameters<F>, ReturnType<F>>): F; | ||
/** | ||
* Creates a tracing context that can be used to trace a method call | ||
*/ | ||
createTrace(): any; | ||
} | ||
/** | ||
* Infer the yielded type of an (async)iterable | ||
*/ | ||
type YieldType<T extends AsyncIterator<any> | Iterator<any>> = T extends AsyncIterator<infer Y> ? Y : T extends Iterator<infer Y, any, any> ? Y : never; | ||
export type TraceAttributes = Record<string, number | string | boolean | number[] | string[] | boolean[]>; | ||
export interface TraceFunctionOptions<A, B> { | ||
/** | ||
* To construct a trace that spans multiple method invocations, it's necessary | ||
* to pass the trace context onwards as part of the options object. | ||
* | ||
* Specify the index of the options object in the args array here. | ||
* | ||
* @default 0 | ||
*/ | ||
optionsIndex?: number; | ||
/** | ||
* Set attributes on the trace by modifying the passed attributes object. | ||
*/ | ||
getAttributesFromArgs?(args: A, attributes: TraceAttributes): TraceAttributes; | ||
/** | ||
* Set attributes on the trace by modifying the passed attributes object. The | ||
* object will have previously been passed to `appendAttributesFromArgs` | ||
* and/or `appendAttributesFromYieldedValue` (if defined) | ||
*/ | ||
getAttributesFromReturnValue?(value: B, attributes: TraceAttributes): TraceAttributes; | ||
} | ||
export interface TraceGeneratorFunctionOptions<A, B, C = any> extends TraceFunctionOptions<A, B> { | ||
/** | ||
* Set attributes on the trace by modifying the passed attributes object. The | ||
* object will have previously been passed to `appendAttributesFromArgs` (if | ||
* defined) | ||
*/ | ||
getAttributesFromYieldedValue?(value: C, attributes: TraceAttributes, index: number): TraceAttributes; | ||
} | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@libp2p/interface", | ||
"version": "2.3.0-127abe24b", | ||
"version": "2.3.0-20d9ba73e", | ||
"description": "The interface implemented by a libp2p node", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0 OR MIT", |
@@ -1,2 +0,2 @@ | ||
import type { AbortOptions, RoutingOptions } from '../index.js' | ||
import type { RoutingOptions } from '../index.js' | ||
import type { PeerInfo } from '../peer-info/index.js' | ||
@@ -53,3 +53,3 @@ import type { CID } from 'multiformats/cid' | ||
*/ | ||
cancelReprovide (key: CID, options?: AbortOptions): Promise<void> | ||
cancelReprovide (key: CID, options?: RoutingOptions): Promise<void> | ||
@@ -56,0 +56,0 @@ /** |
@@ -757,2 +757,11 @@ /** | ||
/** | ||
* An object that includes a trace object that is passed onwards. | ||
* | ||
* This is used by metrics method tracing to link function calls together. | ||
*/ | ||
export interface TraceOptions { | ||
trace?: any | ||
} | ||
/** | ||
* When a routing operation involves reading values, these options allow | ||
@@ -763,3 +772,3 @@ * controlling where the values are read from. By default libp2p will check | ||
*/ | ||
export interface RoutingOptions extends AbortOptions, ProgressOptions { | ||
export interface RoutingOptions extends AbortOptions, ProgressOptions, TraceOptions { | ||
/** | ||
@@ -766,0 +775,0 @@ * Pass `false` to not use the network |
@@ -491,2 +491,59 @@ import type { MultiaddrConnection, Stream, Connection } from '../connection/index.js' | ||
registerSummaryGroup: ((name: string, options?: SummaryOptions) => SummaryGroup) & ((name: string, options: CalculatedSummaryOptions<Record<string, number>>) => void) | ||
/** | ||
* Wrap a function for tracing purposes. | ||
* | ||
* All functions wrapped like this should accept a final optional options arg. | ||
* | ||
* In order to pass an execution context along to create a multi-layered | ||
* trace, the index of the options arg must be specified. | ||
*/ | ||
traceFunction <F extends (...args: any[]) => AsyncIterator<any>> (name: string, fn: F, options?: TraceGeneratorFunctionOptions<Parameters<F>, ReturnType<F>, YieldType<ReturnType<F>>>): F | ||
traceFunction <F extends (...args: any[]) => Iterator<any>> (name: string, fn: F, options?: TraceGeneratorFunctionOptions<Parameters<F>, ReturnType<F>, YieldType<ReturnType<F>>>): F | ||
traceFunction <F extends (...args: any[]) => any = (...args: any[]) => any> (name: string, fn: F, options?: TraceFunctionOptions<Parameters<F>, ReturnType<F>>): F | ||
/** | ||
* Creates a tracing context that can be used to trace a method call | ||
*/ | ||
createTrace(): any | ||
} | ||
/** | ||
* Infer the yielded type of an (async)iterable | ||
*/ | ||
type YieldType<T extends AsyncIterator<any> | Iterator<any>> = T extends AsyncIterator<infer Y> ? Y : T extends Iterator<infer Y, any, any> ? Y : never | ||
export type TraceAttributes = Record<string, number | string | boolean | number[] | string[] | boolean[]> | ||
export interface TraceFunctionOptions<A, B> { | ||
/** | ||
* To construct a trace that spans multiple method invocations, it's necessary | ||
* to pass the trace context onwards as part of the options object. | ||
* | ||
* Specify the index of the options object in the args array here. | ||
* | ||
* @default 0 | ||
*/ | ||
optionsIndex?: number | ||
/** | ||
* Set attributes on the trace by modifying the passed attributes object. | ||
*/ | ||
getAttributesFromArgs?(args: A, attributes: TraceAttributes): TraceAttributes | ||
/** | ||
* Set attributes on the trace by modifying the passed attributes object. The | ||
* object will have previously been passed to `appendAttributesFromArgs` | ||
* and/or `appendAttributesFromYieldedValue` (if defined) | ||
*/ | ||
getAttributesFromReturnValue?(value: B, attributes: TraceAttributes): TraceAttributes | ||
} | ||
export interface TraceGeneratorFunctionOptions<A, B, C = any> extends TraceFunctionOptions<A, B> { | ||
/** | ||
* Set attributes on the trace by modifying the passed attributes object. The | ||
* object will have previously been passed to `appendAttributesFromArgs` (if | ||
* defined) | ||
*/ | ||
getAttributesFromYieldedValue? (value: C, attributes: TraceAttributes, index: number): TraceAttributes | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
310315
7620