pub struct EnrollmentJournal { /* private fields */ }Expand description
Append-only enrollment-intent journal. Append serialization is enforced, not assumed (review F1):
- In-process:
record_intentfunnels every append through a process-global cached writer map (parking_lotmutex): one instance per directory, opened once and reused — concurrent async signup/login handlers serialize on the mutex, and exactly one open file description ever holds the flock in this process. A long-livedEnrollmentJournal’s&mut selfappend is compile-time serialized. - Cross-process:
opentakes a non-blocking exclusiveflock(2)onenrollment-intents.lockin the journal directory and holds it for the instance’s lifetime; a second opener — in any process, including this one — fails closed withJournalError::Locked. Two processes must never share one journal directory; the reconciler reads by taking the same lock after the writer is done.
Keep the journal directory on the OAuth host’s local filesystem: flock
and the fsync ordering above are not reliable over 9P/NFS-style shared
mounts.
Implementations§
Source§impl EnrollmentJournal
impl EnrollmentJournal
Sourcepub fn open(dir: impl AsRef<Path>) -> Result<Self, JournalError>
pub fn open(dir: impl AsRef<Path>) -> Result<Self, JournalError>
Open (creating if necessary) the journal under dir, reading and
validating every committed record. A corrupt or gapped journal fails
closed: open errors rather than guessing at recovery. Takes the
cross-process writer lock (see the type docs).
Sourcepub fn append(
&mut self,
intent: EnrollmentIntent,
) -> Result<AppendOutcome, JournalError>
pub fn append( &mut self, intent: EnrollmentIntent, ) -> Result<AppendOutcome, JournalError>
Append an intent, applying the idempotency / fail-closed conflict
rules. The record is durable (file + directory fsync) before this
returns Committed or Conflict.
Sourcepub fn records(&self) -> &[JournalRecord]
pub fn records(&self) -> &[JournalRecord]
All committed records in sequence order — the reconciler’s read API.
Sourcepub fn iter(
&self,
) -> impl ExactSizeIterator<Item = &JournalRecord> + DoubleEndedIterator
pub fn iter( &self, ) -> impl ExactSizeIterator<Item = &JournalRecord> + DoubleEndedIterator
Iterate committed records in sequence order.
Sourcepub fn intents(&self) -> impl Iterator<Item = (u64, &EnrollmentIntent)>
pub fn intents(&self) -> impl Iterator<Item = (u64, &EnrollmentIntent)>
Iterate committed (non-conflict) intents with their sequences. This is the stream the reconciler folds into the next unsigned policy generation; conflict records are excluded and must be handled separately by the operator.
Sourcepub fn conflicts(&self) -> impl Iterator<Item = (u64, &ConflictRecord)>
pub fn conflicts(&self) -> impl Iterator<Item = (u64, &ConflictRecord)>
Iterate conflict records with their sequences.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Auto Trait Implementations§
impl Freeze for EnrollmentJournal
impl RefUnwindSafe for EnrollmentJournal
impl Send for EnrollmentJournal
impl Sync for EnrollmentJournal
impl Unpin for EnrollmentJournal
impl UnsafeUnpin for EnrollmentJournal
impl UnwindSafe for EnrollmentJournal
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request