Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 13 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ jobs:
name: Tests (Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
timeout-minutes: 20
env:
REDBEAT_TEST_REDIS_SERVER: /usr/bin/redis-server
strategy:
fail-fast: false
max-parallel: 4
matrix:
os: [ubuntu-latest] #, windows-latest] tests fail on windows
# Python 3.9 builds are available for Ubuntu 24.04, not 26.04.
os: [ubuntu-24.04]
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
Comment on lines +31 to 33

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maybe we can move from python 3.9? it is not supported for long time


steps:
Expand All @@ -45,8 +48,15 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements-dev.txt

- name: Run unittests
run: make unittests
- name: Install Redis test binary
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends --yes redis-server

- name: Run unit and isolated Redis tests
run: |
test -x "$REDBEAT_TEST_REDIS_SERVER"
make test

lint:
name: Lint
Expand Down
53 changes: 53 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
Splunk-maintained changes
------------------------------------
These additions are maintained in splunk/redbeat and are recorded separately
from the upstream RedBeat release history below.

- Add RedBeatSchedulerEntry.save_with_first_due() to create an interval
entry with an application-selected timezone-aware first due time.
Normalize it to UTC while preserving fractional seconds in metadata.
Store its definition, run metadata, due score and policy fingerprint
together, without allowing immediate execution to bypass that time.
- Add update_definition() to change a managed entry's payload without
moving its saved due time or replacing accepted immediate-run state.
- Preserve an optional opaque jitter_fingerprint on reload and support
first_run_kwargs for the first outgoing managed invocation only.
Later reservations continue the ordinary interval schedule.
- Guard managed reservations and definition updates against conflicting
Redis writes, changed run state and deletion. Preserve newer payloads
and immediate requests. Retry WATCH conflicts up to three total attempts.
Ordinary managed reservations do not rewrite an unchanged definition.
- Add the optional redbeat_entry_policy callback to select the following
due time and applied policy during reservation. Keep the current stored
run unchanged. Allow applications to adopt, replace or remove a policy
without adding their timing rules to RedBeat.
- Add request_run() for an application-selected managed refresh deadline.
Keep the earliest pending deadline and latest payload. Reuse the existing
immediate flag and interval metadata rather than a separate request record.
Due or overdue requests prompt selection without bypassing the due check.
- Add save_guarded() for ordinary entries that may acquire a managed policy.
Assign an entry_id on guarded creation and reject stale writes after
deletion and recreation under the same key. Keep existing legacy entries
without an identity unchanged instead of assigning one during reload.
Assign the caller's creation identity only after the Redis write succeeds.
- Raise EntryAlreadyExists, a ValueError subtype, when either creation API
finds a winning entry. First-due creation uses the same three-attempt
WATCH handling so callers can distinguish this race from invalid input.
- Store policy fingerprints and creation identities as JSON values so both
text and byte Redis responses use the same decoding path.
- Keep from_key() on the existing HGET pipeline pattern, without duplicate
identity reads or load-time retries. Remove the associated selection-error
handler and obsolete tests. Guarded writes retain their identity checks.
Non-transactional reads can still mix records during same-key replacement.
- Add unit and isolated Redis, Beat and worker integration coverage.
Cover following-run policies, managed refreshes, same-key replacement,
concurrent writes, legacy entries and Redis Cluster managed operations.
Run tests with pytest and retain Python 3.9 CI support by using Ubuntu
24.04 test runners with an explicitly installed Redis test binary.

Applications remain responsible for offset calculation and timing policy.
RedBeat supplies persistence and the optional following-run policy hook,
not a jitter configuration flag or application-specific lifecycle rules.
Entries without managed state or a policy requesting adoption retain their
existing scheduling path.

2.4.2 (2026-07-27)
---------------------
- bugfix, restore the pre-2.4.0 handling of options inherited from
Expand Down
29 changes: 29 additions & 0 deletions docs/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,32 @@ As a result most datetime objects need to be timezone aware.
due_at, returns aware datetime
to_timestamp(), accepts aware datetime, returns seconds since epoch (UTC)
score(), returns seconds since epoch for due_at

Explicit interval deadlines
~~~~~~~~~~~~~~~~~~~~~~~~~~~

The opt-in ``save_with_first_due()`` and ``request_run()`` methods accept
timezone-aware deadlines. RedBeat converts them to UTC before calculating the
matching interval anchor. Fractional seconds in the deadline and interval are
preserved in JSON metadata. These methods require a positive, non-relative
interval schedule. Calendar schedules and relative rounding do not use this
anchor calculation. Other scheduling APIs keep their existing behavior.

The optional ``redbeat_entry_policy`` callback can select a following deadline
under the same rules. It does not move the current saved invocation. Applications
own their policy, including any jitter window, identity hashing, whole-second
rounding or exceptions for urgent work. RedBeat stores the supplied timing and
protects managed writes against concurrent updates and schedule replacement.

Redis lookup scores retain their existing whole-second precision. A candidate
can therefore be selected before a fractional deadline. The full-precision due
check still prevents early publication. Beat wake-up frequency, broker latency
and worker capacity can delay dispatch or execution. Subsecond timing is not a
real-time execution guarantee.

Entry loading follows the existing pipeline read pattern. Standalone Redis and
Sentinel use the client's default transactional pipeline. A non-transactional
read, including a default Cluster pipeline, does not guarantee a consistent
snapshot if another client deletes and recreates the same key during that read.
There is no load-time retry or duplicate identity read. Managed writes still
check the loaded creation identity and applied policy before saving.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ docs:
$(MAKE) -C docs/ html

unittests:
python -m unittest discover tests
python -m pytest tests

clean:
rm -f dist/*
Expand Down
Loading
Loading