Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a394aea
added concurrent, cumulative and windowed stategies for redis_mutex
jwoodrow Mar 24, 2025
b913f7e
fix specs and add a github action workflow (it's free for opensource
jwoodrow Mar 25, 2025
9d1e661
forgot env var and add concurrency cancellation
jwoodrow Mar 25, 2025
1b17063
never remember if it's service name or localhost
jwoodrow Mar 25, 2025
6643830
try localhost then ?
jwoodrow Mar 25, 2025
25138e9
remove vscode settings.json
jwoodrow Mar 25, 2025
0430da2
use docker redis ?
jwoodrow Mar 25, 2025
e0286d8
need to add ports
jwoodrow Mar 25, 2025
4c9d7d6
localhost again
jwoodrow Mar 25, 2025
5bcffff
ellipsis is ruby 3+ and safe navigation is ruby 2.3+
jwoodrow Mar 25, 2025
f9a54d8
go back in time and give up on kwargs
jwoodrow Mar 25, 2025
7ab5f17
add a delete_key method to prioritize unlink
jwoodrow Mar 25, 2025
9f6a64f
present? is active_support
jwoodrow Mar 25, 2025
9bf73a0
can't compact in older versions of ruby
jwoodrow Mar 25, 2025
09340c7
added a devcontainer to help debug old ruby version (maybe should con…
jwoodrow Mar 25, 2025
064a2a7
add a Dockerfile for each matrixed version of the gem for easier debu…
jwoodrow Mar 25, 2025
b9a0942
actually dockerignore has no effect on devcontainers
jwoodrow Mar 25, 2025
929cb8e
add some empty lines
jwoodrow Mar 25, 2025
9e1b338
I don't want a spec file to appear as a diff for this
jwoodrow Mar 25, 2025
c8b585b
fix an error in ruby 2.1
jwoodrow Mar 25, 2025
f72c1f7
Merge branch 'master' into alternative_mutex_strategies
jwoodrow Dec 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ruby:latest

RUN apt-get update && apt-get install -y bash git vim && rm -rf /var/lib/apt/lists/*

RUN gem install bundler
23 changes: 23 additions & 0 deletions .devcontainer/Dockerfile.2.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Need to build using rbenv because these are very old ruby verions and their images need rebuilding to work anyways
FROM debian:bullseye

SHELL ["/bin/bash","-l","-c"]

# Install dependencies
RUN apt-get update
RUN apt-get install ghostscript shared-mime-info openssl curl gnupg2 dirmngr git-core libcurl4-openssl-dev software-properties-common zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libffi-dev libpq-dev libmagickcore-6.q16-dev -y

# Install rbenv & ruby-build
RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv
RUN echo 'export PATH="~/.rbenv/bin:$PATH"' >> ~/.bashrc
RUN echo 'eval "$(rbenv init -)"' >> ~/.bashrc

RUN git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
RUN echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc

# Install ruby
RUN rbenv rehash
RUN rbenv install 2.1.10
RUN rbenv global 2.1.10

RUN gem install bundler -v '< 2'
23 changes: 23 additions & 0 deletions .devcontainer/Dockerfile.2.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Need to build using rbenv because these are very old ruby verions and their images need rebuilding to work anyways
FROM debian:bullseye

SHELL ["/bin/bash","-l","-c"]

# Install dependencies
RUN apt-get update
RUN apt-get install ghostscript shared-mime-info openssl curl gnupg2 dirmngr git-core libcurl4-openssl-dev software-properties-common zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libffi-dev libpq-dev libmagickcore-6.q16-dev -y

# Install rbenv & ruby-build
RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv
RUN echo 'export PATH="~/.rbenv/bin:$PATH"' >> ~/.bashrc
RUN echo 'eval "$(rbenv init -)"' >> ~/.bashrc

RUN git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
RUN echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc

# Install ruby
RUN rbenv rehash
RUN rbenv install 2.2.10
RUN rbenv global 2.2.10

RUN gem install bundler -v '< 2'
23 changes: 23 additions & 0 deletions .devcontainer/Dockerfile.2.3.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Need to build using rbenv because these are very old ruby verions and their images need rebuilding to work anyways
FROM debian:bullseye

SHELL ["/bin/bash","-l","-c"]

# Install dependencies
RUN apt-get update
RUN apt-get install ghostscript shared-mime-info openssl curl gnupg2 dirmngr git-core libcurl4-openssl-dev software-properties-common zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libffi-dev libpq-dev libmagickcore-6.q16-dev -y

# Install rbenv & ruby-build
RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv
RUN echo 'export PATH="~/.rbenv/bin:$PATH"' >> ~/.bashrc
RUN echo 'eval "$(rbenv init -)"' >> ~/.bashrc

RUN git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
RUN echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc

# Install ruby
RUN rbenv rehash
RUN rbenv install 2.3.0
RUN rbenv global 2.3.0

RUN gem install bundler -v '< 2'
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile.2.7.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ruby:2.7.0

RUN apt-get update && apt-get install -y bash git vim && rm -rf /var/lib/apt/lists/*

RUN gem install bundler
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile.3.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ruby:3.0

RUN apt-get update && apt-get install -y bash git vim && rm -rf /var/lib/apt/lists/*

RUN gem install bundler
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile.3.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ruby:3.1

RUN apt-get update && apt-get install -y bash git vim && rm -rf /var/lib/apt/lists/*

RUN gem install bundler
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile.3.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ruby:3.2

RUN apt-get update && apt-get install -y bash git vim && rm -rf /var/lib/apt/lists/*

RUN gem install bundler
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile.3.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ruby:3.3

RUN apt-get update && apt-get install -y bash git vim && rm -rf /var/lib/apt/lists/*

RUN gem install bundler
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile.3.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ruby:3.4

RUN apt-get update && apt-get install -y bash git vim && rm -rf /var/lib/apt/lists/*

RUN gem install bundler
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/docker-existing-docker-compose
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
{
"name": "Redis Mutex",

// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": "./docker-compose.yml",

// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "app",

// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/app",
"shutdownAction": "stopCompose",

"mounts": [
"source=${localEnv:HOME}/.ssh,target=/root/.ssh,type=bind,consistency=cached"
],

"postAttachCommand": "git config --global --add safe.directory /app",
}
52 changes: 52 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: '3'
name: redis-mutex
networks:
redis-mutex:
name: redis-mutex
external: false
volumes:
redis_data:
name: 'redis-mutex-redis-data'
redis_shared_data:
name: 'redis-mutex-redis-data'
services:
redis:
image: redis:7-alpine
command: redis-server
container_name: redis-mutex-redis
volumes:
- 'redis_shared_data:/var/shared/redis:delegated'
- 'redis_data:/data:delegated'
networks:
- redis-mutex
expose:
- 6379
healthcheck:
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
interval: 10s
timeout: 5s
retries: 2
start_period: 10s
restart: unless-stopped
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile.2.1
image: redis-mutex
container_name: redis-mutex
pull_policy: build
volumes:
- '..:/app:cached'
networks:
- redis-mutex
stdin_open: true
tty: true
environment:
BUNDLE_PATH: /app/vendor/bundle
REDIS_URL: redis://redis:6379/1
CI: true
entrypoint: ['/bin/bash', '-l', '-c']
command: '"tail -f /dev/null"'
depends_on:
redis:
condition: service_healthy
45 changes: 45 additions & 0 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: RSpec

on:
pull_request:

env:
CI: true
REDIS_URL: redis://localhost:6379/1

concurrency:
group: ${{ github.event.repository.name }}-${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

jobs:
rspec:
name: RSpec
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
ruby-version: [2.1, 2.2, 2.3.0, 2.7.0, 3.0, 3.1, 3.2, 3.3, 3.4]

services:
redis:
image: public.ecr.aws/docker/library/redis:7-alpine
ports:
- "6379:6379"
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Run rspec
run: bundle exec rspec
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pkg
Gemfile.lock
vendor
spec/examples.txt
12 changes: 0 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"

# RSpec
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new('spec')
task :default => :spec

# Custom Tasks
desc 'Flush the test database'
task :flushdb do
require 'redis'
Redis.new(:db => 15).flushdb
end
Loading
Loading