Skip to content

Commit

Permalink
Update CI and exports
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-marcacci committed Jul 25, 2021
1 parent 7da6045 commit 03fc063
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 20 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "13:00"
open-pull-requests-limit: 10
67 changes: 67 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Continuous Integration

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
name: Test with Node.js v${{ matrix.node }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest"]
node: ["16"]
services:
redis_single_instance:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

redis_multi_instance_a:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
redis_multi_instance_b:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
redis_multi_instance_c:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install dependancies
run: yarn install --frozen-lockfile
- name: Lint the source
run: yarn lint
- name: Transpile into dist
run: yarn build
- name: Run tests
run: yarn test
29 changes: 29 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "CodeQL"

on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "43 22 * * 6"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: ["javascript"]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
[![npm version](https://badge.fury.io/js/redlock.svg)](https://www.npmjs.com/package/redlock)
[![Build Status](https://travis-ci.org/mike-marcacci/node-redlock.svg)](https://travis-ci.org/mike-marcacci/node-redlock)
[![Coverage Status](https://coveralls.io/repos/mike-marcacci/node-redlock/badge.svg)](https://coveralls.io/r/mike-marcacci/node-redlock)
[![Continuous Integration](https://github.com/mike-marcacci/node-redlock/workflows/Continuous%20Integration/badge.svg)](https://github.com/mike-marcacci/node-redlock/actions/workflows/ci.yml)
[![Current Version](https://badgen.net/npm/v/redlock)](https://npm.im/redlock)
[![Supported Node.js Versions](https://badgen.net/npm/node/redlock)](https://npm.im/redlock)

# Redlock

This is a node.js implementation of the [redlock](http://redis.io/topics/distlock) algorithm for distributed redis locks. It provides strong guarantees in both single-redis and multi-redis environments, and provides fault tolerance through use of multiple independent redis instances or clusters.

- [Installation](#installation)
- [Usage (Promise Style)](#usage-promise-style)
- [Usage (Disposer Style)](#usage-disposer-style)
- [Usage (Callback Style)](#usage-callback-style)
- [Locking multiple resources](#locking-multiple-resources)
- [API Docs](#api-docs)
- [Usage](#usage)

### High-Availability Recommendations

Expand Down Expand Up @@ -80,6 +76,10 @@ const redlock = new Redlock(
// to improve performance under high contention
// see https://www.awsarchitectureblog.com/2015/03/backoff.html
retryJitter: 200, // time in ms

// The minimum remaining time on a lock before an extension is automatically
// attempted with the `using` API.
automaticExtensionThreshold: 500, // time in ms
}
);
```
Expand Down Expand Up @@ -141,3 +141,7 @@ await somethingElse();
// Release the lock.
await lock.release();
```

## API

Please view the (very concise) source code or TypeScript definitions for a detailed breakdown of the API.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ services:
- redis_single_instance
image: node:16
working_dir: /workspace
command: ./scripts/await.sh node_modules/.bin/ava ./scripts/await.sh dist/redlock.js yarn test:development
command: ./scripts/await.sh node_modules/.bin/ava ./scripts/await.sh dist/index.js yarn test:development
environment:
NODE_ENV: development
volumes:
Expand Down
25 changes: 17 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,26 @@
"redis"
],
"files": [
"dist/index.js"
"dist/index.d.ts",
"dist/index.js",
"dist/index.js.map"
],
"engines": {
"node": ">=12"
},
"browserslist": "node >= 10",
"browserslist": "node >= 12",
"ava": {
"nodeArguments": [
"--experimental-specifier-resolution=node"
]
},
"devDependencies": {
"@types/ioredis": "^4.17.8",
"@types/node": "^16.3.2",
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"@types/ioredis": "^4.26.6",
"@types/node": "^16.4.2",
"@typescript-eslint/eslint-plugin": "^4.28.4",
"@typescript-eslint/parser": "^4.28.4",
"ava": "^3.13.0",
"eslint": "^7.14.0",
"eslint": "^7.31.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.2.0",
"ioredis": "^4.19.2",
Expand All @@ -49,5 +56,7 @@
"prepare": "yarn build",
"prepublishOnly": "yarn install && yarn lint && yarn build && yarn test"
},
"dependencies": {}
"dependencies": {},
"type": "module",
"exports": "./dist/index.js"
}
2 changes: 1 addition & 1 deletion src/redlock.test.ts → src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from "ava";
import Client from "ioredis";
import Redlock, { ExecutionError, ResourceLockedError } from "./redlock";
import Redlock, { ExecutionError, ResourceLockedError } from "./index.js";

const redis = new Client({ host: "redis_single_instance" });
test.before(async () => {
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
"compilerOptions": {
"lib": ["es2020"],
"target": "es2020",
"module": "commonjs",
"module": "es2020",
"outDir": "./dist",
"declaration": true,
"declarationDir": "./dist",
"moduleResolution": "node",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"skipLibCheck": false,
"sourceMap": true
},
"include": ["./src/**/*"]
Expand Down

0 comments on commit 03fc063

Please sign in to comment.