Repository navigation
Add atomic batch creation for stored schedules - #119
Merged
Merged
Conversation
Expose django_ox.stored.create_schedules(rows, *, user=None) as a public, stable API. Pass a list of mappings with the fields create_schedule accepts to create schedules that should exist together. Validate every row and require unique names within the batch. Report all validation failures in one ValidationError, with row index, name, field and message. Check permissions only after the whole batch validates. PermissionDenied names every denied row before any write. Use one clock reading for the batch. Save all schedules in one write-only transaction on their destination database and tell workers once. A concurrent name conflict raises IntegrityError and rolls back the whole batch. An empty batch returns []. Validate integer fields against the destination database's range. create_schedule, update_schedule and the admin form now report field errors for values that a narrower routed database cannot store. Report field validation errors for non-numeric values in every_seconds, phase_seconds or starting_deadline_seconds, phase_seconds=None, mixed naive and aware time bounds, and empty values in every_seconds, starting_deadline_seconds or end_time. These inputs previously raised TypeError in create_schedule and at the validation step in update_schedule. Callers that handled TypeError for these inputs should now handle ValidationError. In update_schedule, non-numeric every_seconds and phase_seconds still raise a ValidationError with no field at an earlier step; that behavior is unchanged. Document the stored-schedule write functions as public. No migration is needed. Stored-schedule dispatch is unchanged. Tests cover each behavior the change adds or alters.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Expose django_ox.stored.create_schedules(rows, *, user=None) as a public,
stable API for schedules that should exist together.
The function validates every row and requires unique names within the
batch. One ValidationError reports every validation failure by row
index, name, field and message. Permission checks follow validation,
with PermissionDenied naming every denied row before any write.
The batch shares one clock reading. A write-only transaction on the
destination database saves every schedule and tells workers once.
A concurrent name conflict raises IntegrityError and rolls back the
whole batch. An empty batch returns [].
What changes for callers
mappings with the fields create_schedule accepts.
message. The index is zero-based; field is "" for a failure that
belongs to no one field.
create_schedule, update_schedule and the admin form now report field
errors for values that would previously fail at the database write.
phase_seconds or starting_deadline_seconds, phase_seconds=None, mixed
naive and aware time bounds, and empty values in every_seconds,
starting_deadline_seconds or end_time. These inputs previously raised
TypeError in create_schedule and at the validation step in
update_schedule. In update_schedule, non-numeric every_seconds and
phase_seconds still raise a ValidationError with no field at an
earlier step; that behavior is unchanged.
both fail immediately with "database is locked" inside a caller's
transaction.atomic() that has already read if another connection
holds the write lock.
The stored-schedule write functions are documented as public. No
migration is needed. Stored-schedule dispatch is unchanged.
Tests cover each behavior the change adds or alters.