MCPcopy Create free account
hub / github.com/subquery/subql / send

Method send

packages/node/src/indexer/x-provider/http.ts:165–189  ·  view source on GitHub ↗

* @summary Send HTTP POST Request with Body to configured HTTP Endpoint.

(
    method: string,
    params: unknown[],
    isCacheable?: boolean,
  )

Source from the content-addressed store, hash-verified

163 * @summary Send HTTP POST Request with Body to configured HTTP Endpoint.
164 */
165 async send<T>(
166 method: string,
167 params: unknown[],
168 isCacheable?: boolean,
169 ): Promise<T> {
170 this.#stats.total.requests++;
171
172 const [, body] = this.#coder.encodeJson(method, params);
173 let resultPromise: Promise<T> | null = isCacheable
174 ? (this.#callCache.get(body) as Promise<T>)
175 : null;
176
177 // eslint-disable-next-line @typescript-eslint/no-misused-promises
178 if (!resultPromise) {
179 resultPromise = this._send(body);
180
181 if (isCacheable) {
182 this.#callCache.set(body, resultPromise);
183 }
184 } else {
185 this.#stats.total.cached++;
186 }
187
188 return resultPromise;
189 }
190
191 async _send<T>(body: string): Promise<T> {
192 this.#stats.active.requests++;

Callers 1

x-provider.spec.tsFile · 0.45

Calls 3

_sendMethod · 0.95
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected