Skip to content

Commit

Permalink
[Cases] Case action: Error handling and retries (#173012)
Browse files Browse the repository at this point in the history
## Summary

This PR:

1. Creates the `CasesConnectorError` error
2. Separate the execution logic by moving the current logic to a new
class called `CasesConnectorExecutor`
3. Let the `CasesConnector` class handle only the retry logic of the
connector
4. Implements the [Full jitter backoff
algorithm](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/)
which is used as the retry strategy of the connector

Depends on: #172709

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
cnasikas and kibanamachine authored Jan 12, 2024
1 parent a1a9840 commit 4f81c0c
Show file tree
Hide file tree
Showing 13 changed files with 3,453 additions and 1,350 deletions.
932 changes: 134 additions & 798 deletions x-pack/plugins/cases/server/connectors/cases/cases_connector.test.ts

Large diffs are not rendered by default.

586 changes: 34 additions & 552 deletions x-pack/plugins/cases/server/connectors/cases/cases_connector.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { CaseError } from '../../common/error';

export class CasesConnectorError extends Error {
public readonly statusCode: number;

constructor(message: string, statusCode: number) {
super(message);

this.statusCode = statusCode;
}
}

export const isCasesConnectorError = (error: unknown): error is CasesConnectorError =>
error instanceof CasesConnectorError;

export const isCasesClientError = (error: unknown): error is CaseError =>
error instanceof CaseError;
Loading

0 comments on commit 4f81c0c

Please sign in to comment.