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

Adds timeout functions to sdk/base package #7617

Merged
merged 6 commits into from
Apr 6, 2021
Merged

Adds timeout functions to sdk/base package #7617

merged 6 commits into from
Apr 6, 2021

Conversation

alecps
Copy link
Contributor

@alecps alecps commented Apr 5, 2021

Description

In our efforts to improve ODIS scalability, the CAP team came across the need for these timeout async functions and they seemed like something that should be added to the base package.

We've added retryAsyncWithBackOffWithTimeout() and timeout(). The former retries an async function up to a given number of times with a backoff between each retry and caps the attempt to call the function with a timeout. The timeout() function simply calls an async function and wraps the promise in a timeout.

Authorship credit goes to @codyborn who wrote the timeout logic in a separate PR

Tested

Unit tests added to async.test.ts

Related issues

None

Backwards compatibility

Yes

Documentation

None

@alecps alecps requested review from barbaraliau, medhakothari and a team as code owners April 5, 2021 23:14
@alecps alecps requested review from nambrot, codyborn and a team and removed request for barbaraliau and medhakothari April 5, 2021 23:14
Copy link
Contributor

@codyborn codyborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also bump the package version and update the release notes:
https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/CHANGELOG.md#L0-L1
cc @medhak1

@yorhodes
Copy link
Contributor

yorhodes commented Apr 5, 2021

IIRC sdk/utils is more likely the appropriate place for this.

We don't want to pollute sdk/base with anything that isn't directly useful in the bundle. In this case it might be "tree-shaken" out or not relevant because you haven't added any dependencies but more as an FYI. cc @gastonponti

@alecps alecps force-pushed the alecps/odisBase branch 3 times, most recently from c8cb56b to 1a716ae Compare April 6, 2021 00:45
@alecps alecps added the automerge Have PR merge automatically when checks pass label Apr 6, 2021
@alecps alecps force-pushed the alecps/odisBase branch from 6d5e0a2 to ed9040e Compare April 6, 2021 00:58
@alecps alecps removed the request for review from mcortesi April 6, 2021 00:59
@mergify mergify bot merged commit f61fb56 into master Apr 6, 2021
@mergify mergify bot deleted the alecps/odisBase branch April 6, 2021 02:04
alecps added a commit that referenced this pull request Apr 6, 2021
* Adds timeout functions to sdk/base package (#7617)

### Description

In our efforts to improve ODIS scalability, the CAP team came across the need for these timeout async functions and they seemed like something that should be added to the base package. 

We've added retryAsyncWithBackOffWithTimeout() and timeout(). The former retries an async function up to a given number of times with a backoff between each retry and caps the attempt to call the function with a timeout. The timeout() function simply calls an async function and wraps the promise in a timeout.

Authorship credit goes to @codyborn who wrote the timeout logic in a separate PR 

### Tested

Unit tests added to async.test.ts

### Related issues

None

### Backwards compatibility

Yes

### Documentation

None

* adds requestID to logger in common pkg

* assign sessionID in combiner if not provided by client

* bumps common package version

* bumps package versions

* ODIS Combiner Reliability (#7594)

### Description

- Adding timeouts to full-node requests
- “Failing open” when timeouts are hit
- Forcing outstanding request termination when k of m signatures have been collected
- Forcing outstanding request termination and returning early when k of m signatures are not possible

### Tested

- Test cases for new async method wrapper
- TODO: Deploy to alfajores and perform load tests to measure impact

### Backwards compatibility

Yes

### Documentation

N/A

* export base through common package

* bumps common pkg version

* bumps pkgs in signer

Co-authored-by: Cody Born <codyborn@outlook.com>
alecps added a commit that referenced this pull request Apr 6, 2021
* adds timeouts to signer

* moves timeout function to base package, adds signer timeout metric

* udpates dependency graph

* fixes typo

* fixes error

* adds backup timeout at express level

* addresses feedback

* import timeout through common package

* moves backup timeout to better spot

* removes commented out code

* parallelizes db ops

* adds TODOS

* adds timeout helper to sdk/base

* adds retryAsyncWithTimeout helper to sdk/base

* refactors retryAsyncWithBackOffAndTimeout() to use timeout()

* bumps package version and updates changelog

* adds docs

* Revert "bumps package version and updates changelog"

This reverts commit ed9040e.

* Adds timeout functions to sdk/base package (#7617)

### Description

In our efforts to improve ODIS scalability, the CAP team came across the need for these timeout async functions and they seemed like something that should be added to the base package. 

We've added retryAsyncWithBackOffWithTimeout() and timeout(). The former retries an async function up to a given number of times with a backoff between each retry and caps the attempt to call the function with a timeout. The timeout() function simply calls an async function and wraps the promise in a timeout.

Authorship credit goes to @codyborn who wrote the timeout logic in a separate PR 

### Tested

Unit tests added to async.test.ts

### Related issues

None

### Backwards compatibility

Yes

### Documentation

None

* add full node timeouts to signer

* adds db timeouts to signer

* adds dependency graph

* ODIS Combiner Reliability (#7594)

### Description

- Adding timeouts to full-node requests
- “Failing open” when timeouts are hit
- Forcing outstanding request termination when k of m signatures have been collected
- Forcing outstanding request termination and returning early when k of m signatures are not possible

### Tested

- Test cases for new async method wrapper
- TODO: Deploy to alfajores and perform load tests to measure impact

### Backwards compatibility

Yes

### Documentation

N/A

* ODIS load test (#7602)

Integrates load test logic into monitor

* update dependency graph

* adds sdk/base to signer dockerfile (temporary)

Co-authored-by: Cody Born <codyborn@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Have PR merge automatically when checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants