Skip to content
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

fix(api-elasticsearch): health and node checks #4143

Merged
merged 5 commits into from
May 22, 2024

Conversation

brunozoric
Copy link
Contributor

@brunozoric brunozoric commented May 21, 2024

Changes

This PR introduces Elasticsearch/OpenSearch health and node checks.
They need to be called manually, but they will help with determining if the cluster is good for writes/reads.

How Has This Been Tested?

Jest.

Usage

// Configure the utility.
const waitUntilHealthy = createWaitUntilHealthy(client, {
    minStatus: ElasticsearchCatHealthStatus.Yellow,
    maxProcessorPercent: 101,
    maxWaitingTime: 30,
    waitingTimeStep: 5,
    maxRamPercent: 101
});
// Wait until the cluster is healthy.
// It will throw an error on Abort and on Timeout (when maxWaitingTime is hit).
const { runs, runningTime } = await waitUntilHealthy.wait({
    async onUnhealthy(params) {
        const { runs, startedAt, mustEndAt, waitingTimeStep } = params;
    },
    async onTimeout(params) {
        const { runs, startedAt, mustEndAt, waitingTimeStep } = params;
        // log some info?
    }
});

// continue with your regular code

@brunozoric brunozoric self-assigned this May 21, 2024
@brunozoric brunozoric marked this pull request as ready for review May 22, 2024 09:28
@brunozoric brunozoric merged commit d4a3c0c into dev May 22, 2024
80 of 81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants