-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2377 from kuzzleio/2.19.1-proposal
# [2.19.3](https://github.com/kuzzleio/kuzzle/releases/tag/2.19.3) (2022-08-08) #### Bug fixes - [ [#2372](#2372) ] Allow to use vault key from env ([Aschen](https://github.com/Aschen)) #### Enhancements - [ [#2376](#2376) ] Add type for BackendPlugin.get ([Aschen](https://github.com/Aschen)) - [ [#2364](#2364) ] Better notification dispatch pipe ([Shiranuit](https://github.com/Shiranuit)) - [ [#2329](#2329) ] Add kuzzle config settings for internal index's number of shards and replicas ([ChillPC](https://github.com/ChillPC))
- Loading branch information
Showing
29 changed files
with
20,454 additions
and
8,385 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,65 @@ | ||
--- | ||
code: false | ||
type: page | ||
title: wait | ||
description: Mutex class wait() method | ||
--- | ||
|
||
# wait | ||
|
||
<SinceBadge version="2.19.1"/> | ||
|
||
```js | ||
async wait ({ attemptDelay = this.attemptDelay, timeout = this.timeout }): Promise<boolean> { | ||
``` | ||
Wait for the ressource specified in the promise to be unlocked. | ||
<br/> | ||
| Arguments | Type | Description | | ||
| ------------------- | ----------------- | -------------------------------------------------------------------------------------------- | | ||
| `options` | <pre>object</pre> | (optional) Mutex override options (see below) | | ||
### options | ||
The `options` object is used to override some mutex properties for this function. The following properties can be provided: | ||
| Option | Type | Description | | ||
| -------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------- | | ||
| `attemptDelay` | <pre>number</pre> | (default: `this.attemptDelay`) Delay in milliseconds between resource check attempts | | ||
| `timeout` | <pre>number</pre> | (default: `this.timeout`) Mutex check attempt timeout, in milliseconds. If set to 0, wait will return immediately, whether it the resource is locked within the 1st attempt. If set to -1, the mutex will wait for the resource to be free indefinitely | | ||
<br/> | ||
## Returns | ||
True if the ressource has been unlocked before the `timeout` | ||
--- | ||
## Usage | ||
Waiting indefinitely until a resource is available: | ||
```ts | ||
import { Mutex } from 'kuzzle'; | ||
|
||
async function ConcurrentAccessMethod () { | ||
const mutex = new Mutex( | ||
'concurrentAccessMethodResource', { timeout: 0 }); | ||
|
||
if (await mutex.lock())) { | ||
try { | ||
// Initialize shared stuff | ||
} | ||
finally { | ||
await mutex.unlock(); | ||
} | ||
} | ||
} | ||
else { | ||
mutex.wait({ timeout: -1 }); // Wait for shared stuff to be initialized | ||
} | ||
} | ||
``` |
Oops, something went wrong.