@enterprise_search/indexing
Advanced tools
Comparing version 0.5.0 to 0.5.1
export * from './src/access'; | ||
export * from './src/column.details'; | ||
export * from './src/fetch.log'; | ||
export * from './src/forest.index'; | ||
@@ -4,0 +5,0 @@ export * from './src/index.config.defaults'; |
@@ -19,2 +19,3 @@ "use strict"; | ||
__exportStar(require("./src/column.details"), exports); | ||
__exportStar(require("./src/fetch.log"), exports); | ||
__exportStar(require("./src/forest.index"), exports); | ||
@@ -21,0 +22,0 @@ __exportStar(require("./src/index.config.defaults"), exports); |
@@ -36,5 +36,12 @@ import { NameAnd } from "@laoban/utils"; | ||
export type FetchMethod = 'Get' | 'Post' | 'Put' | 'Delete'; | ||
export type HeadersOrFn = NameAnd<string> | (() => Promise<NameAnd<string>>); | ||
export declare function headersFrom(h: HeadersOrFn): Promise<NameAnd<string>>; | ||
export declare function optionsFrom(o: FetchFnOptions | undefined): Promise<{ | ||
headers: NameAnd<string>; | ||
method?: FetchMethod; | ||
body?: string; | ||
}>; | ||
export type FetchFnOptions = { | ||
method?: FetchMethod; | ||
headers?: NameAnd<string>; | ||
headers?: HeadersOrFn; | ||
body?: string; | ||
@@ -44,3 +51,3 @@ }; | ||
export type FetchUrlFn = (url: string) => Promise<any>; | ||
export declare function toUrlFn(fetch: FetchFn, options: (url: string) => FetchFnOptions): FetchUrlFn; | ||
export declare function toUrlFn(fetch: FetchFn, optionsFn: (url: string) => Promise<FetchFnOptions>): FetchUrlFn; | ||
export declare function cacheUrlFn(fetch: FetchFn, cache?: NameAnd<Promise<FetchFnResponse>>): FetchUrlFn; | ||
@@ -47,0 +54,0 @@ export declare function callFetch(fetchFn: FetchFn, url: string, options?: FetchFnOptions, prefix?: string): Promise<any>; |
@@ -19,3 +19,3 @@ "use strict"; | ||
console.log(`Fetching: ${url}`); | ||
const res = await (0, node_fetch_1.default)(url, options); | ||
const res = await (0, node_fetch_1.default)(url, await (0, access_1.optionsFrom)(options)); | ||
const headers = {}; | ||
@@ -22,0 +22,0 @@ res.headers.forEach((value, name) => { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.access = exports.nullAccessConfig = exports.consoleIndexingContext = exports.defaultIndexingContext = exports.callFetch = exports.cacheUrlFn = exports.toUrlFn = exports.findVarsFrom = exports.defaultAuthFn = exports.getOrUpdateEntraId = exports.authForEntraId = void 0; | ||
exports.access = exports.nullAccessConfig = exports.consoleIndexingContext = exports.defaultIndexingContext = exports.callFetch = exports.cacheUrlFn = exports.toUrlFn = exports.optionsFrom = exports.headersFrom = exports.findVarsFrom = exports.defaultAuthFn = exports.getOrUpdateEntraId = exports.authForEntraId = void 0; | ||
const tree_index_1 = require("./tree.index"); | ||
@@ -79,2 +79,5 @@ const forest_index_1 = require("./forest.index"); | ||
} | ||
const doubleCheck = tokenCache[key]; //double sync check. the await in the above check can cause multiple fetches. Only causes wasted calls..but still... | ||
if (doubleCheck && (await doubleCheck).expires > timeService()) | ||
return (await doubleCheck).token; | ||
const newToken = authForEntraIdFn(process.env, fetch, oauth).then((token) => { | ||
@@ -128,7 +131,19 @@ if (!token.token) | ||
exports.findVarsFrom = findVarsFrom; | ||
function toUrlFn(fetch, options) { | ||
async function headersFrom(h) { | ||
return typeof h === 'function' ? await h() : h; | ||
} | ||
exports.headersFrom = headersFrom; | ||
async function optionsFrom(o) { | ||
if (!o) | ||
return undefined; | ||
const { headers, ...rest } = o; | ||
return { ...rest, headers: await headersFrom(headers) }; | ||
} | ||
exports.optionsFrom = optionsFrom; | ||
function toUrlFn(fetch, optionsFn) { | ||
return async (url) => { | ||
async function getData() { | ||
try { | ||
return await fetch(url, options(url)); | ||
const options = await optionsFn(url); | ||
return await fetch(url, options); | ||
} | ||
@@ -177,4 +192,2 @@ catch (e) { | ||
const u = new URL(url); | ||
const domainKey = 'fetch.' + u.hostname; | ||
metrics[domainKey] = metrics[domainKey] ? metrics[domainKey] + 1 : 1; | ||
try { | ||
@@ -184,2 +197,4 @@ const result = await fetch(url, options); | ||
console.error(`loading ${url} failed with ${result.status} ${result.statusText}`); | ||
const domainKey = 'fetch.' + result.status + '.' + u.hostname; | ||
metrics[domainKey] = metrics[domainKey] ? metrics[domainKey] + 1 : 1; | ||
return result; | ||
@@ -189,2 +204,4 @@ } | ||
console.error(e); | ||
const domainKey = 'fetch.error.' + u.hostname; | ||
metrics[domainKey] = metrics[domainKey] ? metrics[domainKey] + 1 : 1; | ||
throw e; | ||
@@ -220,3 +237,3 @@ } | ||
method: method || 'Get', | ||
headers: headers, | ||
headers: async () => headers, | ||
body: body | ||
@@ -223,0 +240,0 @@ }); |
@@ -12,3 +12,4 @@ export type NameAndValueColumn = { | ||
export declare function toJsonFromNameAndValue(nameAndValue?: NameAndValueColumn[]): Record<string, string>; | ||
export declare function removeHtmlTags(text: string): string; | ||
export declare function valueFromColumnDetails(details: ColumnDetails, value?: string): string; | ||
export declare const toColumnDetails: (raw: (string | ColumnDetails)[]) => ColumnDetails[]; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toColumnDetails = exports.valueFromColumnDetails = exports.toJsonFromNameAndValue = void 0; | ||
const cheerio_1 = __importDefault(require("cheerio")); | ||
exports.toColumnDetails = exports.valueFromColumnDetails = exports.removeHtmlTags = exports.toJsonFromNameAndValue = void 0; | ||
const cheerio = __importStar(require("cheerio")); | ||
function toJsonFromNameAndValue(nameAndValue) { | ||
@@ -16,3 +36,3 @@ if (!nameAndValue) | ||
try { | ||
let $ = cheerio_1.default.load(text); | ||
let $ = cheerio.load(text); | ||
return $('body').text(); | ||
@@ -24,2 +44,3 @@ } | ||
} | ||
exports.removeHtmlTags = removeHtmlTags; | ||
function valueFromColumnDetails(details, value) { | ||
@@ -26,0 +47,0 @@ if (details.value) |
@@ -7,5 +7,4 @@ "use strict"; | ||
function addNonFunctionalsToIndexForestTc(nf, tc) { | ||
const { queryConcurrencyLimit, queryThrottle, queryRetryPolicy, queryQueue } = nf; | ||
return { | ||
fetchForest: (0, kleislis_1.withRetry)(queryRetryPolicy, (0, kleislis_1.withConcurrencyLimit)(queryConcurrencyLimit, queryQueue, (0, kleislis_1.withThrottle)(queryThrottle, tc.fetchForest))), | ||
fetchForest: (0, kleislis_1.withNonFunctionals)(nf.query, 'fetchForest', tc.fetchForest), | ||
treeIds: tc.treeIds, | ||
@@ -12,0 +11,0 @@ treeToString: tc.treeToString |
@@ -10,5 +10,6 @@ import { IndexTreeNonFunctionals } from "./indexing.non.functionals"; | ||
export declare function insertIntoFile<T>(ins: InsertIntoFile<T>): Indexer<T>; | ||
export declare const insertIntoFileWithNonFunctionals: (rootDir: string, fileTemplate: string, _index: string, nf: IndexTreeNonFunctionals) => Indexer<unknown>; | ||
export declare function addFileToQueue(file: string, data: string[]): void; | ||
export declare const insertIntoFileWithNonFunctionals: (rootDir: string, fileTemplate: string, _index: string, nf: IndexTreeNonFunctionals) => Indexer<any>; | ||
export declare const addToFile: <T>(file: string, ins: InsertIntoFile<T>, data: string[], s: string) => Promise<void>; | ||
export declare function appendFile<T>(file: string, data: string[]): Promise<void>; | ||
export {}; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.appendFile = exports.addToFile = exports.insertIntoFileWithNonFunctionals = exports.insertIntoFile = void 0; | ||
exports.appendFile = exports.addToFile = exports.insertIntoFileWithNonFunctionals = exports.addFileToQueue = exports.insertIntoFile = void 0; | ||
const promises_1 = __importDefault(require("fs/promises")); | ||
@@ -13,2 +13,3 @@ const utils_1 = require("@laoban/utils"); | ||
const utils_2 = require("@itsmworkbench/utils"); | ||
const kleislis_1 = require("@enterprise_search/kleislis"); | ||
function insertIntoFile(ins) { | ||
@@ -39,2 +40,28 @@ const { max } = ins; | ||
exports.insertIntoFile = insertIntoFile; | ||
const queue = []; | ||
const appendWithRetry = (0, kleislis_1.withRetry)(kleislis_1.defaultRetryPolicy, appendFile); | ||
let processing = false; | ||
async function getOffQueue() { | ||
if (processing) | ||
return; | ||
processing = true; | ||
try { | ||
while (queue.length > 0) { | ||
const { file, data } = queue.shift(); | ||
await appendWithRetry(file, data); | ||
} | ||
} | ||
catch (e) { | ||
console.error(e); | ||
} | ||
finally { | ||
processing = false; | ||
setImmediate(getOffQueue); | ||
} | ||
} | ||
function addFileToQueue(file, data) { | ||
queue.push({ file, data }); | ||
setImmediate(getOffQueue); | ||
} | ||
exports.addFileToQueue = addFileToQueue; | ||
const insertIntoFileWithNonFunctionals = (rootDir, fileTemplate, _index, nf) => (0, tree_index_1.addNonFunctionsToIndexer)(nf, insertIntoFile({ | ||
@@ -47,3 +74,3 @@ file: (id) => { | ||
max: 5, | ||
formatter: (rootId, _id, data) => `${JSON.stringify({ index: { _index, _id } })}\n${JSON.stringify(data)}\n` | ||
formatter: (rootId, _id, data) => `${JSON.stringify({ ...data, _index, _id })}\n` | ||
})); | ||
@@ -55,3 +82,4 @@ exports.insertIntoFileWithNonFunctionals = insertIntoFileWithNonFunctionals; | ||
if (data.length >= max) { | ||
await appendFile(file, data); | ||
queue.push({ file, data: [...data] }); | ||
setImmediate(getOffQueue); | ||
data.length = 0; | ||
@@ -58,0 +86,0 @@ } |
@@ -62,3 +62,3 @@ "use strict"; | ||
return { | ||
fetchParent: (0, kleislis_1.withRetry)(nf.queryRetryPolicy, (0, kleislis_1.withConcurrencyLimit)(nf.queryConcurrencyLimit, nf.queryQueue, (0, kleislis_1.withThrottle)(nf.queryThrottle, tc.fetchParent))), | ||
fetchParent: (0, kleislis_1.withNonFunctionals)(nf.query, 'fetchParent', tc.fetchParent), | ||
children: (parentId, parent) => tc.children(parentId, parent) | ||
@@ -65,0 +65,0 @@ }; |
@@ -1,19 +0,14 @@ | ||
import { RetryPolicyConfig, Task, Throttling } from "@enterprise_search/kleislis"; | ||
import { NonFunctionals, RetryPolicyConfig, Throttling } from "@enterprise_search/kleislis"; | ||
import { PopulatedIndexItem } from "@enterprise_search/indexconfig"; | ||
export type IndexTreeNonFunctionals = { | ||
queryQueue: Task<any>[]; | ||
queryConcurrencyLimit: number; | ||
queryThrottle: Throttling; | ||
queryRetryPolicy: RetryPolicyConfig; | ||
indexQueue: Task<any>[]; | ||
indexThrottle: Throttling; | ||
indexName: string; | ||
query: NonFunctionals; | ||
index: NonFunctionals; | ||
prepareLeafRetryPolicy: RetryPolicyConfig; | ||
indexRetryPolicy: RetryPolicyConfig; | ||
indexerConcurrencyLimit: number; | ||
}; | ||
export declare function treeNonFunctionalsFromConfig(indexItem: PopulatedIndexItem): IndexTreeNonFunctionals; | ||
export declare function treeNonFunctionals(queryThrottle: Throttling, retryPolicy: RetryPolicyConfig, indexThrottle: Throttling, concurrencyLimit?: number, indexerConcurrencyLimit?: number): IndexTreeNonFunctionals; | ||
export declare function treeNonFunctionalsFromConfig(indexName: string, indexItem: PopulatedIndexItem): IndexTreeNonFunctionals; | ||
export declare function treeNonFunctionals(indexName: string, queryThrottle: Throttling, retryPolicy: RetryPolicyConfig, indexThrottle: Throttling, concurrencyLimit?: number, indexerConcurrencyLimit?: number): IndexTreeNonFunctionals; | ||
export declare const queryThrottlePrototype: Throttling; | ||
export declare const indexThrottlePrototype: Throttling; | ||
export declare const treeRetryPolicy: RetryPolicyConfig; | ||
export declare function defaultIndexTreeNfs(): IndexTreeNonFunctionals; | ||
export declare function defaultIndexTreeNfs(indexName: string): IndexTreeNonFunctionals; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.defaultIndexTreeNfs = exports.treeRetryPolicy = exports.indexThrottlePrototype = exports.queryThrottlePrototype = exports.treeNonFunctionals = exports.treeNonFunctionalsFromConfig = void 0; | ||
function treeNonFunctionalsFromConfig(indexItem) { | ||
const kleislis_1 = require("@enterprise_search/kleislis"); | ||
function treeNonFunctionalsFromConfig(indexName, indexItem) { | ||
return { | ||
queryQueue: [], | ||
queryConcurrencyLimit: indexItem.query.concurrencyLimit || 1000, | ||
queryThrottle: indexItem.query.throttle, | ||
queryRetryPolicy: indexItem.query.retry, | ||
indexQueue: [], | ||
indexThrottle: indexItem.target.throttle, | ||
indexName, | ||
query: { | ||
concurrencyLimits: (0, kleislis_1.defaultConcurrencyLimits)(indexItem.query.concurrencyLimit), | ||
throttle: indexItem.query.throttle, | ||
retry: indexItem.query.retry | ||
}, | ||
index: { | ||
concurrencyLimits: (0, kleislis_1.defaultConcurrencyLimits)(indexItem.target.concurrencyLimit), | ||
throttle: indexItem.target.throttle, | ||
retry: indexItem.target.retry | ||
}, | ||
prepareLeafRetryPolicy: indexItem.target.retry, | ||
indexRetryPolicy: indexItem.target.retry, | ||
indexerConcurrencyLimit: indexItem.target.concurrencyLimit | ||
}; | ||
} | ||
exports.treeNonFunctionalsFromConfig = treeNonFunctionalsFromConfig; | ||
function treeNonFunctionals(queryThrottle, retryPolicy, indexThrottle, concurrencyLimit = 1000, indexerConcurrencyLimit = 2) { | ||
function treeNonFunctionals(indexName, queryThrottle, retryPolicy, indexThrottle, concurrencyLimit = 1000, indexerConcurrencyLimit = 2) { | ||
return { | ||
queryQueue: [], | ||
queryConcurrencyLimit: concurrencyLimit, | ||
queryThrottle, | ||
queryRetryPolicy: retryPolicy, | ||
indexerConcurrencyLimit, | ||
indexQueue: [], | ||
indexThrottle, | ||
indexName, | ||
query: { | ||
concurrencyLimits: (0, kleislis_1.defaultConcurrencyLimits)(concurrencyLimit), | ||
throttle: queryThrottle, | ||
retry: retryPolicy | ||
}, | ||
index: { | ||
concurrencyLimits: (0, kleislis_1.defaultConcurrencyLimits)(indexerConcurrencyLimit), | ||
throttle: indexThrottle, | ||
retry: retryPolicy | ||
}, | ||
prepareLeafRetryPolicy: retryPolicy, | ||
indexRetryPolicy: retryPolicy | ||
}; | ||
@@ -41,5 +48,5 @@ } | ||
}; | ||
function defaultIndexTreeNfs() { | ||
return treeNonFunctionals({ ...exports.queryThrottlePrototype }, exports.treeRetryPolicy, { ...exports.indexThrottlePrototype }); | ||
function defaultIndexTreeNfs(indexName) { | ||
return treeNonFunctionals(indexName, { ...exports.queryThrottlePrototype }, exports.treeRetryPolicy, { ...exports.indexThrottlePrototype }); | ||
} | ||
exports.defaultIndexTreeNfs = defaultIndexTreeNfs; |
import { AccessConfig, FetchFn, FetchFnOptions, FetchFnResponse } from "./access"; | ||
import { IndexParentChildLogAndMetrics } from "./index.parent.child"; | ||
import { RetryPolicyConfig } from "@enterprise_search/kleislis"; | ||
export declare const noPagingAccessConfig: AccessConfig<NoPaging>; | ||
@@ -22,5 +21,5 @@ export type WithPaging<T, P> = { | ||
export declare function fetchOneItem(fetch: FetchFn): FetchOneItemType; | ||
export declare function fetchWithPaging<P>(fetchFn: FetchFn, log: IndexParentChildLogAndMetrics, tc: PagingTc<P>, retry?: RetryPolicyConfig): <T>(url: string, options?: FetchFnOptions, valueFn?: (json: any) => Promise<T>) => AsyncGenerator<T, void>; | ||
export declare function fetchWithPaging<P>(fetchFn: FetchFn, log: IndexParentChildLogAndMetrics, tc: PagingTc<P>): <T>(url: string, options?: FetchFnOptions, valueFn?: (json: any) => Promise<T>) => AsyncGenerator<T, void>; | ||
export type FetchArrayWithPagingType = <T>(url: string, options?: FetchFnOptions, resfn?: (response: FetchFnResponse) => Promise<T[]>) => AsyncGenerator<T, void>; | ||
export declare function fetchArrayWithPaging<P>(fetch: FetchFn, log: IndexParentChildLogAndMetrics, tc: PagingTc<P>, retry?: RetryPolicyConfig): FetchArrayWithPagingType; | ||
export declare function fetchArrayWithPaging<P>(fetch: FetchFn, log: IndexParentChildLogAndMetrics, tc: PagingTc<P>): FetchArrayWithPagingType; | ||
export type TreeTc<T> = { | ||
@@ -27,0 +26,0 @@ treeUrl: (baseUrl: string, treeId: string) => string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fetchLeavesForTree = exports.fetchArrayWithPaging = exports.fetchWithPaging = exports.fetchOneItem = exports.mapWithPaging = exports.NoPagingTc = exports.noPagingAccessConfig = void 0; | ||
const kleislis_1 = require("@enterprise_search/kleislis"); | ||
exports.noPagingAccessConfig = { | ||
@@ -56,4 +55,4 @@ pagingFn: (json, linkHeader) => ({}) | ||
}; | ||
function fetchWithPaging(fetchFn, log, tc, retry) { | ||
const f = (0, kleislis_1.withRetry)(retry, fetchOneForPaging(fetchFn, tc, log)); | ||
function fetchWithPaging(fetchFn, log, tc) { | ||
const f = fetchOneForPaging(fetchFn, tc, log); | ||
return async function* (url, options, valueFn) { | ||
@@ -72,4 +71,4 @@ let paging = tc.zero(); | ||
exports.fetchWithPaging = fetchWithPaging; | ||
function fetchArrayWithPaging(fetch, log, tc, retry) { | ||
const f = fetchWithPaging(fetch, log, tc, retry); | ||
function fetchArrayWithPaging(fetch, log, tc) { | ||
const f = fetchWithPaging(fetch, log, tc); | ||
return async function* (url, options, resfn) { | ||
@@ -76,0 +75,0 @@ for await (const item of f(url, options, resfn)) { |
@@ -7,10 +7,8 @@ "use strict"; | ||
function addNonFunctionalsToIndexTreeTC(nf, tc) { | ||
const queue = []; | ||
const { queryConcurrencyLimit, queryThrottle, queryRetryPolicy, indexThrottle, prepareLeafRetryPolicy, indexRetryPolicy } = nf; | ||
return { | ||
folderIds: tc.folderIds, | ||
leafIds: tc.leafIds, | ||
fetchFolder: (0, kleislis_1.withRetry)(queryRetryPolicy, (0, kleislis_1.withConcurrencyLimit)(queryConcurrencyLimit, queue, (0, kleislis_1.withThrottle)(queryThrottle, tc.fetchFolder))), | ||
fetchLeaf: (0, kleislis_1.withRetry)(queryRetryPolicy, (0, kleislis_1.withConcurrencyLimit)(queryConcurrencyLimit, queue, (0, kleislis_1.withThrottle)(queryThrottle, tc.fetchLeaf))), | ||
prepareLeaf: rootId => (0, kleislis_1.withRetry)(prepareLeafRetryPolicy, (0, kleislis_1.withConcurrencyLimit)(queryConcurrencyLimit, queue, tc.prepareLeaf(rootId))) | ||
fetchFolder: (0, kleislis_1.withNonFunctionals)(nf.query, 'fetchFolder', tc.fetchFolder), | ||
fetchLeaf: (0, kleislis_1.withNonFunctionals)(nf.query, 'fetchLeft', tc.fetchLeaf), | ||
prepareLeaf: rootId => (0, kleislis_1.withNonFunctionals)(nf.query, 'prepareLeaf', tc.prepareLeaf(rootId)), | ||
}; | ||
@@ -20,8 +18,7 @@ } | ||
function addNonFunctionsToIndexer(nf, indexer) { | ||
const { indexerConcurrencyLimit, queryThrottle, queryRetryPolicy, indexThrottle, prepareLeafRetryPolicy, indexRetryPolicy, queryQueue, indexQueue } = nf; | ||
return { | ||
start: (0, kleislis_1.withRetry)(queryRetryPolicy, (0, kleislis_1.withConcurrencyLimit)(indexerConcurrencyLimit, queryQueue, (0, kleislis_1.withThrottle)(queryThrottle, indexer.start))), | ||
processLeaf: (rootId, id) => (0, kleislis_1.withRetry)(prepareLeafRetryPolicy, (0, kleislis_1.withConcurrencyLimit)(indexerConcurrencyLimit, indexQueue, indexer.processLeaf(rootId, id))), | ||
finished: (0, kleislis_1.withRetry)(queryRetryPolicy, (0, kleislis_1.withConcurrencyLimit)(indexerConcurrencyLimit, indexQueue, (0, kleislis_1.withThrottle)(queryThrottle, indexer.finished))), | ||
failed: (0, kleislis_1.withRetry)(queryRetryPolicy, (0, kleislis_1.withConcurrencyLimit)(indexerConcurrencyLimit, indexQueue, (0, kleislis_1.withThrottle)(queryThrottle, indexer.failed))), | ||
start: (0, kleislis_1.withNonFunctionals)(nf.index, 'start', indexer.start), | ||
processLeaf: (rootId, id) => (0, kleislis_1.withNonFunctionals)(nf.index, 'processLeaf', indexer.processLeaf(rootId, id)), | ||
finished: (0, kleislis_1.withNonFunctionals)(nf.index, 'finished', indexer.finished), | ||
failed: (0, kleislis_1.withNonFunctionals)(nf.index, 'failed', indexer.failed), | ||
}; | ||
@@ -31,4 +28,4 @@ } | ||
function stopNonFunctionals(nft) { | ||
(0, kleislis_1.stopThrottling)(nft.queryThrottle); | ||
(0, kleislis_1.stopThrottling)(nft.indexThrottle); | ||
(0, kleislis_1.stopThrottling)(nft.query.throttle); | ||
(0, kleislis_1.stopThrottling)(nft.index.throttle); | ||
} | ||
@@ -35,0 +32,0 @@ exports.stopNonFunctionals = stopNonFunctionals; |
@@ -1,3 +0,3 @@ | ||
import { NonFunctionals } from "@enterprise_search/indexconfig"; | ||
import { FetchFn } from "./access"; | ||
export declare const useFetchWithNfcs: (fetch: FetchFn, nfcs?: NonFunctionals) => <T>(block: (fetchFn: FetchFn) => Promise<T>) => Promise<T>; | ||
import { NonFunctionalsDefn } from "@enterprise_search/kleislis"; | ||
export declare const useFetchWithNfcs: (fetch: FetchFn, nfcs?: NonFunctionalsDefn) => <T>(block: (fetchFn: FetchFn) => Promise<T>) => Promise<T>; |
@@ -7,3 +7,3 @@ "use strict"; | ||
const { throttle } = nfcs; | ||
const nfcFetch = nfcs ? (0, kleislis_1.withRetry)(nfcs.retry, (0, kleislis_1.withThrottle)(throttle, (0, kleislis_1.withConcurrencyLimit)(nfcs.concurrencyLimit, [], fetch))) : fetch; | ||
const nfcFetch = nfcs ? (0, kleislis_1.withRetry)(nfcs.retry, (0, kleislis_1.withThrottle)(throttle, (0, kleislis_1.withConcurrencyLimit)(nfcs.concurrencyLimit, [], 'fetch', fetch))) : fetch; | ||
nfcs && (0, kleislis_1.startThrottling)(throttle); | ||
@@ -10,0 +10,0 @@ try { |
{ | ||
"name": "@enterprise_search/indexing", | ||
"description": "general code to help with indexing", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"main": "dist/index", | ||
@@ -27,4 +27,4 @@ "types": "dist/index", | ||
"@itsmworkbench/utils": "0.3.11", | ||
"@enterprise_search/indexconfig": "0.5.0", | ||
"@enterprise_search/kleislis": "0.5.0", | ||
"@enterprise_search/indexconfig": "0.5.1", | ||
"@enterprise_search/kleislis": "0.5.1", | ||
"debug": "^4.3.4" | ||
@@ -31,0 +31,0 @@ }, |
87937
43
1893
+ Added@enterprise_search/indexconfig@0.5.1(transitive)
+ Added@enterprise_search/kleislis@0.5.1(transitive)
- Removed@enterprise_search/indexconfig@0.5.0(transitive)
- Removed@enterprise_search/kleislis@0.5.0(transitive)