-
-
Notifications
You must be signed in to change notification settings - Fork 188
fix: enhance httpDownload with retry logic #931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
69b18f3
fix: enhance httpDownload with retry logic and stall detection
firefoxNX dc90a13
chore: add transpiled files to support git dependencies
firefoxNX ac28b58
fix: Add `MAX_RETRIES` config variable with default value
firefoxNX 338a00c
docs: add documentation for `attemptDownload`
firefoxNX e1990b1
Merge branch 'typegoose:master' into master
firefoxNX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
239 changes: 239 additions & 0 deletions
239
packages/mongodb-memory-server-core/lib/MongoMemoryReplSet.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,239 @@ | ||
| /// <reference types="node" /> | ||
| /// <reference types="node" /> | ||
| import { EventEmitter } from 'events'; | ||
| import { MongoMemoryServer, AutomaticAuth, DisposeOptions } from './MongoMemoryServer'; | ||
| import { Cleanup, ManagerAdvanced } from './util/utils'; | ||
| import { MongoBinaryOpts } from './util/MongoBinary'; | ||
| import { MongoMemoryInstanceOpts, MongoMemoryInstanceOptsBase, StorageEngine } from './util/MongoInstance'; | ||
| import { SpawnOptions } from 'child_process'; | ||
| /** | ||
| * Replica set specific options. | ||
| */ | ||
| export interface ReplSetOpts { | ||
| /** | ||
| * Enable Authentication | ||
| * @default false | ||
| */ | ||
| auth?: AutomaticAuth; | ||
| /** | ||
| * additional command line arguments passed to `mongod` | ||
| * @default [] | ||
| */ | ||
| args?: string[]; | ||
| /** | ||
| * if this number is bigger than "instanceOpts.length", more "generic" servers get started | ||
| * if this number is lower than "instanceOpts.length", no more "generic" servers get started (server count will be "instanceOpts.length") | ||
| * @default 1 | ||
| */ | ||
| count?: number; | ||
| /** | ||
| * add an database into the uri (in mongodb its the auth database, in mongoose its the default database for models) | ||
| * @default "" | ||
| */ | ||
| dbName?: string; | ||
| /** | ||
| * bind to all IP addresses specify `::,0.0.0.0` | ||
| * @default '127.0.0.1' | ||
| */ | ||
| ip?: string; | ||
| /** | ||
| * replSet name | ||
| * @default 'testset' | ||
| */ | ||
| name?: string; | ||
| /** | ||
| * Childprocess spawn options | ||
| * @default {} | ||
| */ | ||
| spawn?: SpawnOptions; | ||
| /** | ||
| *`mongod` storage engine type | ||
| * @default 'ephemeralForTest' unless mongodb version is `7.0.0`, where its `wiredTiger` | ||
| */ | ||
| storageEngine?: StorageEngine; | ||
| /** | ||
| * Options for "rsConfig" | ||
| * @default {} | ||
| */ | ||
| configSettings?: MongoMemoryReplSetConfigSettings; | ||
| /** | ||
| * Options for automatic dispose for "Explicit Resource Management" | ||
| */ | ||
| dispose?: DisposeOptions; | ||
| } | ||
| /** | ||
| * Options for "rsConfig" | ||
| */ | ||
| export interface MongoMemoryReplSetConfigSettings { | ||
| chainingAllowed?: boolean; | ||
| heartbeatTimeoutSecs?: number; | ||
| heartbeatIntervalMillis?: number; | ||
| electionTimeoutMillis?: number; | ||
| catchUpTimeoutMillis?: number; | ||
| } | ||
| /** | ||
| * Options for the replSet | ||
| */ | ||
| export interface MongoMemoryReplSetOpts { | ||
| /** | ||
| * Specific Options to use for some instances | ||
| */ | ||
| instanceOpts: MongoMemoryInstanceOptsBase[]; | ||
| /** | ||
| * Binary Options used for all instances | ||
| */ | ||
| binary: MongoBinaryOpts; | ||
| /** | ||
| * Options used for all instances | ||
| * -> gets overwritten by specific "instanceOpts" | ||
| */ | ||
| replSet: ReplSetOpts; | ||
| } | ||
| /** | ||
| * Enum for "_state" inside "MongoMemoryReplSet" | ||
| */ | ||
| export declare enum MongoMemoryReplSetStates { | ||
| init = "init", | ||
| running = "running", | ||
| stopped = "stopped" | ||
| } | ||
| /** | ||
| * All Events for "MongoMemoryReplSet" | ||
| */ | ||
| export declare enum MongoMemoryReplSetEvents { | ||
| stateChange = "stateChange" | ||
| } | ||
| export interface MongoMemoryReplSet extends EventEmitter { | ||
| emit(event: MongoMemoryReplSetEvents, ...args: any[]): boolean; | ||
| on(event: MongoMemoryReplSetEvents, listener: (...args: any[]) => void): this; | ||
| once(event: MongoMemoryReplSetEvents, listener: (...args: any[]) => void): this; | ||
| } | ||
| /** | ||
| * Class for managing an replSet | ||
| */ | ||
| export declare class MongoMemoryReplSet extends EventEmitter implements ManagerAdvanced { | ||
| /** | ||
| * All servers this ReplSet instance manages | ||
| */ | ||
| servers: MongoMemoryServer[]; | ||
| /** Options for individual instances */ | ||
| protected _instanceOpts: MongoMemoryInstanceOptsBase[]; | ||
| /** Options for the Binary across all instances */ | ||
| protected _binaryOpts: MongoBinaryOpts; | ||
| /** Options for the Replset itself and defaults for instances */ | ||
| protected _replSetOpts: Required<ReplSetOpts>; | ||
| /** TMPDIR for the keyfile, when auth is used */ | ||
| protected _keyfiletmp?: string; | ||
| protected _state: MongoMemoryReplSetStates; | ||
| protected _ranCreateAuth: boolean; | ||
| constructor(opts?: Partial<MongoMemoryReplSetOpts>); | ||
| /** | ||
| * Change "this._state" to "newState" and emit "newState" | ||
| * @param newState The new State to set & emit | ||
| */ | ||
| protected stateChange(newState: MongoMemoryReplSetStates, ...args: any[]): void; | ||
| /** | ||
| * Create an instance of "MongoMemoryReplSet" and call start | ||
| * @param opts Options for the ReplSet | ||
| */ | ||
| static create(opts?: Partial<MongoMemoryReplSetOpts>): Promise<MongoMemoryReplSet>; | ||
| /** | ||
| * Get Current state of this class | ||
| */ | ||
| get state(): MongoMemoryReplSetStates; | ||
| /** | ||
| * Get & Set "instanceOpts" | ||
| * @throws if "state" is not "stopped" | ||
| */ | ||
| get instanceOpts(): MongoMemoryInstanceOptsBase[]; | ||
| set instanceOpts(val: MongoMemoryInstanceOptsBase[]); | ||
| /** | ||
| * Get & Set "binaryOpts" | ||
| * @throws if "state" is not "stopped" | ||
| */ | ||
| get binaryOpts(): MongoBinaryOpts; | ||
| set binaryOpts(val: MongoBinaryOpts); | ||
| /** | ||
| * Get & Set "replSetOpts" | ||
| * (Applies defaults) | ||
| * @throws if "state" is not "stopped" | ||
| */ | ||
| get replSetOpts(): ReplSetOpts; | ||
| set replSetOpts(val: ReplSetOpts); | ||
| /** | ||
| * Helper function to determine if "auth" should be enabled | ||
| * This function expectes to be run after the auth object has been transformed to a object | ||
| * @returns "true" when "auth" should be enabled | ||
| */ | ||
| protected enableAuth(): boolean; | ||
| /** | ||
| * Returns instance options suitable for a MongoMemoryServer. | ||
| * @param baseOpts Options to merge with | ||
| * @param keyfileLocation The Keyfile location if "auth" is used | ||
| */ | ||
| protected getInstanceOpts(baseOpts?: MongoMemoryInstanceOptsBase, keyfileLocation?: string): MongoMemoryInstanceOpts; | ||
| /** | ||
| * Returns an mongodb URI that is setup with all replSet servers | ||
| * @param otherDb add an database into the uri (in mongodb its the auth database, in mongoose its the default database for models) | ||
| * @param otherIp change the ip in the generated uri, default will otherwise always be "127.0.0.1" | ||
| * @throws if state is not "running" | ||
| * @throws if an server doesnt have "instanceInfo.port" defined | ||
| * @returns an valid mongo URI, by the definition of https://docs.mongodb.com/manual/reference/connection-string/ | ||
| */ | ||
| getUri(otherDb?: string, otherIp?: string): string; | ||
| /** | ||
| * Start underlying `mongod` instances. | ||
| * @throws if state is already "running" | ||
| */ | ||
| start(): Promise<void>; | ||
| /** | ||
| * Initialize & start all servers in the replSet | ||
| */ | ||
| protected initAllServers(): Promise<void>; | ||
| /** | ||
| * Ensure "_keyfiletmp" is defined | ||
| * @returns the ensured "_keyfiletmp" value | ||
| */ | ||
| protected ensureKeyFile(): Promise<string>; | ||
| /** | ||
| * Stop the underlying `mongod` instance(s). | ||
| * @param cleanupOptions Set how to run ".cleanup", by default only `{ doCleanup: true }` is used | ||
| */ | ||
| stop(cleanupOptions?: Cleanup): Promise<boolean>; | ||
| /** | ||
| * Remove the defined dbPath's | ||
| * @param options Set how to run a cleanup, by default `{ doCleanup: true }` is used | ||
| * @throws If "state" is not "stopped" | ||
| * @throws If "instanceInfo" is not defined | ||
| * @throws If an fs error occured | ||
| */ | ||
| cleanup(options?: Cleanup): Promise<void>; | ||
| /** | ||
| * Wait until all instances are running | ||
| * @throws if state is "stopped" (cannot wait on something that dosnt start) | ||
| */ | ||
| waitUntilRunning(): Promise<void>; | ||
| /** | ||
| * Connects to the first server from the list of servers and issues the `replSetInitiate` | ||
| * command passing in a new replica set configuration object. | ||
| * @throws if state is not "init" | ||
| * @throws if "servers.length" is not 1 or above | ||
| * @throws if package "mongodb" is not installed | ||
| */ | ||
| protected _initReplSet(): Promise<void>; | ||
| /** | ||
| * Create the one Instance (without starting them) | ||
| * @param instanceOpts Instance Options to use for this instance | ||
| */ | ||
| protected _initServer(instanceOpts: MongoMemoryInstanceOpts): MongoMemoryServer; | ||
| /** | ||
| * Wait until the replSet has elected a Primary | ||
| * @param timeout Timeout to not run infinitly, default: 30s | ||
| * @param where Extra Parameter for logging to know where this function was called | ||
| * @throws if timeout is reached | ||
| */ | ||
| protected _waitForPrimary(timeout?: number, where?: string): Promise<void>; | ||
| [Symbol.asyncDispose](): Promise<void>; | ||
| } | ||
| export default MongoMemoryReplSet; | ||
| //# sourceMappingURL=MongoMemoryReplSet.d.ts.map |
1 change: 1 addition & 0 deletions
1
packages/mongodb-memory-server-core/lib/MongoMemoryReplSet.d.ts.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this removed and all the generated files included?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am testing in the CI/CD environment with the forked version for which I needed to publish to npm.