journal_machines 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +95 -0
- data/Cargo.lock +321 -0
- data/Cargo.toml +25 -0
- data/LICENSE.txt +21 -0
- data/README.md +401 -0
- data/ext/journal_machines_native/core/CHANGELOG.md +77 -0
- data/ext/journal_machines_native/core/Cargo.toml +18 -0
- data/ext/journal_machines_native/core/README.md +261 -0
- data/ext/journal_machines_native/core/src/checked.rs +161 -0
- data/ext/journal_machines_native/core/src/lib.rs +518 -0
- data/ext/journal_machines_native/core/src/pins.rs +277 -0
- data/ext/journal_machines_native/core/src/policy.rs +95 -0
- data/ext/journal_machines_native/core/src/refusal.rs +105 -0
- data/ext/journal_machines_native/core/src/replace.rs +258 -0
- data/ext/journal_machines_native/core/src/segment.rs +160 -0
- data/ext/journal_machines_native/extconf.rb +2 -0
- data/ext/journal_machines_native/ffi/Cargo.toml +21 -0
- data/ext/journal_machines_native/ffi/extconf.rb +14 -0
- data/ext/journal_machines_native/ffi/src/answers.rs +98 -0
- data/ext/journal_machines_native/ffi/src/classes.rs +46 -0
- data/ext/journal_machines_native/ffi/src/convert.rs +80 -0
- data/ext/journal_machines_native/ffi/src/handles.rs +49 -0
- data/ext/journal_machines_native/ffi/src/init.rs +86 -0
- data/ext/journal_machines_native/ffi/src/lib.rs +432 -0
- data/ext/journal_machines_native/ffi/src/values.rs +97 -0
- data/lib/journal_machines/version.rb +4 -0
- data/lib/journal_machines.rb +138 -0
- data/sig/journal_machines.rbs +209 -0
- metadata +97 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'journal_machines/version'
|
|
4
|
+
|
|
5
|
+
module JournalMachines
|
|
6
|
+
# Roll thresholds and the dead-record ratio that makes a segment worth
|
|
7
|
+
# compacting. A nil threshold never triggers; `max_age` is a span in Integer
|
|
8
|
+
# nanoseconds. Like the core's `Policy::new`, an invalid policy cannot be
|
|
9
|
+
# built: a zero threshold or a ratio above 1000 raises RangeError.
|
|
10
|
+
Policy = Data.define(:max_bytes, :max_records, :max_age, :min_dead_per_mille) do
|
|
11
|
+
def initialize(max_bytes:, max_records:, max_age:, min_dead_per_mille:)
|
|
12
|
+
Journal.__send__(:__check_policy, max_bytes, max_records, max_age, min_dead_per_mille)
|
|
13
|
+
super
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
# Immutable point-in-time view of one segment's metadata. `opened_at` is
|
|
17
|
+
# Integer nanoseconds on the monotonic clock the journal was given. Like the
|
|
18
|
+
# core's `Segment::checked`, it holds only what some journal could answer:
|
|
19
|
+
# anything else raises RangeError (TypeError for a wrong type: Integers,
|
|
20
|
+
# a state Symbol, a retention Symbol (:pinned or :unpinned), a Replacement
|
|
21
|
+
# or nil).
|
|
22
|
+
Segment = Data.define(
|
|
23
|
+
:id, :revision, :base_offset, :records, :stored_records, :live_records,
|
|
24
|
+
:bytes, :opened_at, :state, :retention, :replacement
|
|
25
|
+
) do
|
|
26
|
+
def initialize(id:, revision:, base_offset:, records:, stored_records:, live_records:, bytes:, opened_at:,
|
|
27
|
+
state:, retention:, replacement:)
|
|
28
|
+
Journal.__send__(:__check_segment, [id, revision, base_offset, records],
|
|
29
|
+
[stored_records, live_records, bytes, opened_at], state, retention, replacement)
|
|
30
|
+
super
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def end_offset = base_offset + records
|
|
34
|
+
end
|
|
35
|
+
# Journal#roll_decision when a threshold was reached: the core's
|
|
36
|
+
# `Roll::Due(reason)`. `reason` is :size, :records or :age, checked in that
|
|
37
|
+
# order. The other answer, `Roll::Keep`, is the symbol :keep. Any other
|
|
38
|
+
# Symbol raises RangeError, a non-Symbol TypeError.
|
|
39
|
+
Due = Data.define(:reason) do
|
|
40
|
+
def initialize(reason:)
|
|
41
|
+
Journal.__send__(:__check_due, reason)
|
|
42
|
+
super
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
# A recorded roll: the sealed segment, the new active one and its first
|
|
46
|
+
# offset. Like the core's `Rolled::new`: two issued ids of one scope, the
|
|
47
|
+
# opened one drawn after the sealed one, and a positive next offset, or
|
|
48
|
+
# RangeError (TypeError for a non-Integer).
|
|
49
|
+
Rolled = Data.define(:sealed, :opened, :next_offset) do
|
|
50
|
+
def initialize(sealed:, opened:, next_offset:)
|
|
51
|
+
Journal.__send__(:__check_rolled, sealed, opened, next_offset)
|
|
52
|
+
super
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
# Permission to delete one original segment file. Like the core's
|
|
56
|
+
# `Reclaimed::new`: an issued segment id, a revision of 0 or an attempt drawn
|
|
57
|
+
# after it, and a replaced_by (nil or Integer) later still, or RangeError
|
|
58
|
+
# (TypeError for a non-Integer).
|
|
59
|
+
Reclaimed = Data.define(:segment, :revision, :bytes, :replaced_by) do
|
|
60
|
+
def initialize(segment:, revision:, bytes:, replaced_by:)
|
|
61
|
+
Journal.__send__(:__check_reclaimed, segment, revision, bytes, replaced_by)
|
|
62
|
+
super
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Native is required: no algorithm fallback. It resolves the Data values above
|
|
69
|
+
# once, so they must exist first.
|
|
70
|
+
require 'journal_machines_native/journal_machines_native'
|
|
71
|
+
|
|
72
|
+
module JournalMachines
|
|
73
|
+
# Pin and Replacement handles are values: two handles naming the same pin
|
|
74
|
+
# acquisition or replacement attempt are == and eql?, and hash alike. Only
|
|
75
|
+
# the journal builds them, and they are final like the values below.
|
|
76
|
+
|
|
77
|
+
# The values are final. `initialize` is where each validates, and a subclass
|
|
78
|
+
# could override it, or `allocate` build an instance that never ran it:
|
|
79
|
+
# subclassing raises TypeError and `allocate` is gone. That stops accidents,
|
|
80
|
+
# not reflection (Ruby binds a named subclass's constant before `inherited`
|
|
81
|
+
# raises; `Marshal.load` and a hand-bound `Data#initialize` skip the check),
|
|
82
|
+
# so the extension is the authority: the one value it reads back, a Policy,
|
|
83
|
+
# must be exactly a Policy and is checked again by the core.
|
|
84
|
+
[Policy, Segment, Due, Rolled, Reclaimed, Pin, Replacement].each do |value|
|
|
85
|
+
value.singleton_class.undef_method(:allocate)
|
|
86
|
+
value.define_singleton_method(:inherited) { |_| raise TypeError, "#{value} cannot be subclassed" }
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
class Journal
|
|
90
|
+
private_class_method :__open, :__check_policy, :__check_due, :__check_rolled, :__check_reclaimed,
|
|
91
|
+
:__check_segment
|
|
92
|
+
|
|
93
|
+
# One active segment at `base_offset`, opened at `now`: Integer nanoseconds
|
|
94
|
+
# of a monotonic clock (Process.clock_gettime(Process::CLOCK_MONOTONIC,
|
|
95
|
+
# :nanosecond)). Every later `now` passed to #roll_decision and #roll is
|
|
96
|
+
# read on the same clock. The journal is in scope zero.
|
|
97
|
+
def self.new(policy, base_offset, now) = with_scope(policy, base_offset, now, 0)
|
|
98
|
+
|
|
99
|
+
# As Journal.new, with every segment id, pin generation and attempt number
|
|
100
|
+
# the journal issues carrying `scope`: an Integer in 0..65_535. A journal
|
|
101
|
+
# of another scope answers :stale to its pins and replacements and
|
|
102
|
+
# :unknown to its segment ids. Give each journal its own scope.
|
|
103
|
+
def self.with_scope(policy, base_offset, now, scope) = resumed(policy, base_offset, now, scope, 0)
|
|
104
|
+
|
|
105
|
+
# As Journal.with_scope after a restart: the journal continues the one
|
|
106
|
+
# sequence its ids, generations and attempts are drawn from after
|
|
107
|
+
# `issued`, the #issued saved from the journal before it, so nothing that
|
|
108
|
+
# journal handed out is issued again. Segments and pins are not restored.
|
|
109
|
+
# RangeError when `issued` leaves no number for the active segment.
|
|
110
|
+
# `policy` must be exactly a Policy (TypeError otherwise); the extension
|
|
111
|
+
# reads its fields and checks them again.
|
|
112
|
+
def self.resumed(policy, base_offset, now, scope, issued) = __open(base_offset, now, [scope, issued], policy)
|
|
113
|
+
|
|
114
|
+
def policy = Policy.new(*__policy)
|
|
115
|
+
|
|
116
|
+
def segment_capacity = SEGMENT_CAPACITY
|
|
117
|
+
|
|
118
|
+
def pin_capacity = PIN_CAPACITY
|
|
119
|
+
|
|
120
|
+
# The binding builds every answer (Segment, Rolled, Reclaimed, Due) after
|
|
121
|
+
# the core call, from what the core returned; #roll and #reclaim decide on
|
|
122
|
+
# a copy and keep it only once the answer is built and the journal is
|
|
123
|
+
# still unfrozen and unchanged (FrozenError, RuntimeError otherwise, with
|
|
124
|
+
# nothing applied). #segments,
|
|
125
|
+
# #compaction_candidates and #reclaimable answer at most `limit` segments
|
|
126
|
+
# after segment id `after` (nil to begin), in ascending id order; resume by
|
|
127
|
+
# passing the last id answered. An `after` this journal never issued
|
|
128
|
+
# (another scope, sequence zero, not reached) is no position: [].
|
|
129
|
+
|
|
130
|
+
# Pin a checkpoint at a tracker's confirmed-committed base, under its
|
|
131
|
+
# assignment generation, and move a checkpoint pin to one
|
|
132
|
+
# (#checkpoint_from(pin, tracker)): both are native. The tracker is a
|
|
133
|
+
# sibling gem's value, read by its public `generation` and `base` readers,
|
|
134
|
+
# each asked for before either runs; TypeError naming the reader it lacks.
|
|
135
|
+
|
|
136
|
+
private :__policy
|
|
137
|
+
end
|
|
138
|
+
end
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
module JournalMachines
|
|
2
|
+
VERSION: String
|
|
3
|
+
SEGMENT_CAPACITY: Integer
|
|
4
|
+
PIN_CAPACITY: Integer
|
|
5
|
+
type roll_reason = :size | :records | :age
|
|
6
|
+
type segment_state = :active | :sealed | :proposed | :durable | :reclaimable
|
|
7
|
+
type retention = :unpinned | :pinned
|
|
8
|
+
# Integer nanoseconds on one monotonic clock, for instants and spans alike:
|
|
9
|
+
# Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond). A non-Integer
|
|
10
|
+
# raises TypeError; a value outside 0..2**64-1 raises RangeError.
|
|
11
|
+
type nanoseconds = Integer
|
|
12
|
+
# Every symbol that means "this call was not honoured and changed nothing".
|
|
13
|
+
# One per core `Refusal` variant, no catch-all. Each method below lists
|
|
14
|
+
# exactly the ones it can answer.
|
|
15
|
+
type refusal = :no_active | :empty | :time_regression | :overflow | :segments_full | :pins_full | :exhausted
|
|
16
|
+
| :unknown | :active | :busy | :exceeds | :mismatch | :stale | :wrong_kind | :unassigned
|
|
17
|
+
| :stale_assignment | :regressed | :not_durable | :pinned
|
|
18
|
+
# Honoured idempotent repeats the journal can prove: what was asked for
|
|
19
|
+
# already holds, nothing changed. :unchanged (advance, checkpoint,
|
|
20
|
+
# checkpoint_from) and :already_durable (confirm_rewritten,
|
|
21
|
+
# confirm_superseded, with the payload that was recorded) are answers, not
|
|
22
|
+
# refusals. A second release, reclaim or abort is not one: it is :stale.
|
|
23
|
+
type repeat = :unchanged | :already_durable
|
|
24
|
+
type roll_refusal = :no_active | :empty | :time_regression | :overflow | :segments_full | :exhausted
|
|
25
|
+
type roll_decision_refusal = :no_active | :time_regression | :overflow
|
|
26
|
+
type observe_refusal = :unknown | :active | :exceeds
|
|
27
|
+
type pin_reader_refusal = :pins_full | :exhausted
|
|
28
|
+
type pin_checkpoint_refusal = :unassigned | :pins_full | :exhausted
|
|
29
|
+
type advance_refusal = :stale | :wrong_kind | :regressed
|
|
30
|
+
type checkpoint_refusal = :stale | :wrong_kind | :unassigned | :stale_assignment | :regressed
|
|
31
|
+
type release_refusal = :stale
|
|
32
|
+
type propose_refusal = :unknown | :active | :busy | :exhausted
|
|
33
|
+
type confirm_rewritten_refusal = :stale | :mismatch | :exceeds
|
|
34
|
+
type confirm_superseded_refusal = :stale | :mismatch
|
|
35
|
+
type reclaim_refusal = :stale | :not_durable | :pinned
|
|
36
|
+
type abort_refusal = :stale
|
|
37
|
+
interface _Tracker
|
|
38
|
+
def generation: () -> Integer
|
|
39
|
+
def base: () -> Integer
|
|
40
|
+
end
|
|
41
|
+
# A Pin, a Replacement or a segment id is only meaningful to the Journal
|
|
42
|
+
# that issued it. Each carries that journal's scope in the top 16 bits of
|
|
43
|
+
# its generation, attempt or id, above a number of the one sequence the
|
|
44
|
+
# journal counts from 1 for all three, so no two of them are equal. A
|
|
45
|
+
# Journal that never issued it answers :stale to a Pin or Replacement (nil
|
|
46
|
+
# from pin_offset) and :unknown to a segment id (nil from segment, [] from
|
|
47
|
+
# the scans as a resume position). Two Journals left in the same scope
|
|
48
|
+
# cannot tell their handles apart.
|
|
49
|
+
class Pin
|
|
50
|
+
def kind: () -> (:reader | :checkpoint)
|
|
51
|
+
def generation: () -> Integer
|
|
52
|
+
# The scope of the Journal that issued this pin.
|
|
53
|
+
def scope: () -> Integer
|
|
54
|
+
# A value: equal to, and hashing like, any handle to the same identity.
|
|
55
|
+
def ==: (untyped other) -> bool
|
|
56
|
+
def eql?: (untyped other) -> bool
|
|
57
|
+
def hash: () -> Integer
|
|
58
|
+
end
|
|
59
|
+
class Replacement
|
|
60
|
+
def segment: () -> Integer
|
|
61
|
+
def attempt: () -> Integer
|
|
62
|
+
# The scope of the Journal that issued this attempt.
|
|
63
|
+
def scope: () -> Integer
|
|
64
|
+
# A value: equal to, and hashing like, any handle to the same identity.
|
|
65
|
+
def ==: (untyped other) -> bool
|
|
66
|
+
def eql?: (untyped other) -> bool
|
|
67
|
+
def hash: () -> Integer
|
|
68
|
+
end
|
|
69
|
+
# The core's Policy: same fields, same order, no defaults. A zero threshold
|
|
70
|
+
# or a ratio above 1000 raises RangeError; a non-Integer raises TypeError.
|
|
71
|
+
class Policy < Data
|
|
72
|
+
attr_reader max_bytes: Integer?
|
|
73
|
+
attr_reader max_records: Integer?
|
|
74
|
+
attr_reader max_age: nanoseconds?
|
|
75
|
+
attr_reader min_dead_per_mille: Integer
|
|
76
|
+
def self.new: (Integer? max_bytes, Integer? max_records, nanoseconds? max_age, Integer min_dead_per_mille) -> Policy
|
|
77
|
+
| (max_bytes: Integer?, max_records: Integer?, max_age: nanoseconds?, min_dead_per_mille: Integer) -> Policy
|
|
78
|
+
end
|
|
79
|
+
# The core's Segment. `new` mirrors `Segment::checked`: RangeError unless
|
|
80
|
+
# some journal could answer these eleven values together (an issued id; an
|
|
81
|
+
# active segment holding nothing; a closed one with records >= stored >=
|
|
82
|
+
# live; a replacement exactly when proposed, durable or reclaimable;
|
|
83
|
+
# durable :pinned, reclaimable :unpinned, active :unpinned). TypeError for a
|
|
84
|
+
# wrong type.
|
|
85
|
+
class Segment < Data
|
|
86
|
+
attr_reader id: Integer
|
|
87
|
+
attr_reader revision: Integer
|
|
88
|
+
attr_reader base_offset: Integer
|
|
89
|
+
attr_reader records: Integer
|
|
90
|
+
attr_reader stored_records: Integer
|
|
91
|
+
attr_reader live_records: Integer
|
|
92
|
+
attr_reader bytes: Integer
|
|
93
|
+
attr_reader opened_at: nanoseconds
|
|
94
|
+
attr_reader state: segment_state
|
|
95
|
+
attr_reader retention: retention
|
|
96
|
+
attr_reader replacement: Replacement?
|
|
97
|
+
def self.new: (Integer id, Integer revision, Integer base_offset, Integer records, Integer stored_records,
|
|
98
|
+
Integer live_records, Integer bytes, nanoseconds opened_at, segment_state state, retention retention,
|
|
99
|
+
Replacement? replacement) -> Segment
|
|
100
|
+
| (id: Integer, revision: Integer, base_offset: Integer, records: Integer, stored_records: Integer,
|
|
101
|
+
live_records: Integer, bytes: Integer, opened_at: nanoseconds, state: segment_state, retention: retention,
|
|
102
|
+
replacement: Replacement?) -> Segment
|
|
103
|
+
def end_offset: () -> Integer
|
|
104
|
+
end
|
|
105
|
+
# The core's Roll::Due(reason); Roll::Keep is the symbol :keep. Another
|
|
106
|
+
# Symbol raises RangeError, a non-Symbol TypeError.
|
|
107
|
+
class Due < Data
|
|
108
|
+
attr_reader reason: roll_reason
|
|
109
|
+
def self.new: (roll_reason reason) -> Due
|
|
110
|
+
| (reason: roll_reason) -> Due
|
|
111
|
+
end
|
|
112
|
+
# The core's Rolled. `new` mirrors `Rolled::new`: RangeError unless both ids
|
|
113
|
+
# are issued ids of one scope, opened drawn after sealed, and next_offset is
|
|
114
|
+
# positive. TypeError for a non-Integer.
|
|
115
|
+
class Rolled < Data
|
|
116
|
+
attr_reader sealed: Integer
|
|
117
|
+
attr_reader opened: Integer
|
|
118
|
+
attr_reader next_offset: Integer
|
|
119
|
+
def self.new: (Integer sealed, Integer opened, Integer next_offset) -> Rolled
|
|
120
|
+
| (sealed: Integer, opened: Integer, next_offset: Integer) -> Rolled
|
|
121
|
+
end
|
|
122
|
+
# The core's Reclaimed. `new` mirrors `Reclaimed::new`: RangeError unless the
|
|
123
|
+
# segment id is issued, revision is 0 or an attempt drawn after it, and
|
|
124
|
+
# replaced_by is nil or a later attempt still. TypeError for a non-Integer.
|
|
125
|
+
class Reclaimed < Data
|
|
126
|
+
attr_reader segment: Integer
|
|
127
|
+
attr_reader revision: Integer
|
|
128
|
+
attr_reader bytes: Integer
|
|
129
|
+
attr_reader replaced_by: Integer?
|
|
130
|
+
def self.new: (Integer segment, Integer revision, Integer bytes, Integer? replaced_by) -> Reclaimed
|
|
131
|
+
| (segment: Integer, revision: Integer, bytes: Integer, replaced_by: Integer?) -> Reclaimed
|
|
132
|
+
end
|
|
133
|
+
class Journal
|
|
134
|
+
# A journal in scope zero.
|
|
135
|
+
def self.new: (Policy policy, Integer base_offset, nanoseconds now) -> Journal
|
|
136
|
+
# A journal whose segment ids, pin generations and attempt numbers carry
|
|
137
|
+
# `scope`, an Integer in 0..65_535 (TypeError for a non-Integer,
|
|
138
|
+
# RangeError outside the range).
|
|
139
|
+
def self.with_scope: (Policy policy, Integer base_offset, nanoseconds now, Integer scope) -> Journal
|
|
140
|
+
# A journal of `scope` after a restart, continuing the sequence after
|
|
141
|
+
# `issued`: the #issued saved from the journal before it. Segments and
|
|
142
|
+
# pins are not restored. RangeError for an `issued` outside 0..2**48-2,
|
|
143
|
+
# which would leave no number for the active segment.
|
|
144
|
+
def self.resumed: (Policy policy, Integer base_offset, nanoseconds now, Integer scope, Integer issued) -> Journal
|
|
145
|
+
def scope: () -> Integer
|
|
146
|
+
# How many segment ids, pin generations and attempts, together, the
|
|
147
|
+
# journal has issued. Save it to resume after a restart.
|
|
148
|
+
def issued: () -> Integer
|
|
149
|
+
def policy: () -> Policy
|
|
150
|
+
def segment_capacity: () -> Integer
|
|
151
|
+
def pin_capacity: () -> Integer
|
|
152
|
+
def size: () -> Integer
|
|
153
|
+
def empty?: () -> bool
|
|
154
|
+
def roll_decision: (Integer bytes, Integer records, nanoseconds now) -> (:keep | Due | roll_decision_refusal)
|
|
155
|
+
def roll: (Integer bytes, Integer records, nanoseconds now) -> (Rolled | roll_refusal)
|
|
156
|
+
def observe_live: (Integer id, Integer live_records) -> (:recorded | observe_refusal)
|
|
157
|
+
def active: () -> Segment?
|
|
158
|
+
def segment: (Integer id) -> Segment?
|
|
159
|
+
def covering: (Integer offset) -> Segment?
|
|
160
|
+
# `after` must be an id this journal issued (any of its segment ids, pin
|
|
161
|
+
# generations or attempts, even one whose segment has left); one it never
|
|
162
|
+
# issued (another scope, sequence zero, not reached) is no position: [].
|
|
163
|
+
def segments: (Integer? after, Integer limit) -> Array[Segment]
|
|
164
|
+
def compaction_candidates: (Integer? after, Integer limit) -> Array[Segment]
|
|
165
|
+
def reclaimable: (Integer? after, Integer limit) -> Array[Segment]
|
|
166
|
+
def pin_reader: (Integer offset) -> (Pin | pin_reader_refusal)
|
|
167
|
+
def pin_checkpoint: (Integer assignment, Integer offset) -> (Pin | pin_checkpoint_refusal)
|
|
168
|
+
def pin_checkpoint_from: (_Tracker tracker) -> (Pin | pin_checkpoint_refusal)
|
|
169
|
+
def advance: (Pin, Integer offset) -> (:moved | :unchanged | advance_refusal)
|
|
170
|
+
def checkpoint: (Pin, Integer assignment, Integer offset) -> (:advanced | :reassigned | :unchanged | checkpoint_refusal)
|
|
171
|
+
def checkpoint_from: (Pin, _Tracker tracker) -> (:advanced | :reassigned | :unchanged | checkpoint_refusal)
|
|
172
|
+
# :stale for a pin that is not held: one already released included.
|
|
173
|
+
def release: (Pin) -> (:released | release_refusal)
|
|
174
|
+
def pin_offset: (Pin) -> Integer?
|
|
175
|
+
def low_pin: () -> Integer?
|
|
176
|
+
def pins: () -> Integer
|
|
177
|
+
def propose: (Integer id) -> (Replacement | propose_refusal)
|
|
178
|
+
# The core's confirm_durable(replacement, durable), one method per variant
|
|
179
|
+
# of its `Durable` argument: Rewritten { bytes, live_records } and Superseded.
|
|
180
|
+
# On an attempt that is already durable: :already_durable for the payload
|
|
181
|
+
# that was recorded, :mismatch for any other (the other method, or
|
|
182
|
+
# different bytes or live_records).
|
|
183
|
+
def confirm_rewritten: (Replacement, Integer bytes, Integer live_records) -> (:recorded | :already_durable | confirm_rewritten_refusal)
|
|
184
|
+
def confirm_superseded: (Replacement) -> (:recorded | :already_durable | confirm_superseded_refusal)
|
|
185
|
+
def reclaim: (Replacement) -> (Reclaimed | reclaim_refusal)
|
|
186
|
+
def abort: (Replacement) -> (:aborted | abort_refusal)
|
|
187
|
+
|
|
188
|
+
# Private native hooks. `__open` is the one constructor `new`,
|
|
189
|
+
# `with_scope` and `resumed` reach (scope and issued as a pair, policy
|
|
190
|
+
# last); the `__check_*` hooks validate a Data value's fields at
|
|
191
|
+
# `initialize`, answering nil or raising.
|
|
192
|
+
private def self.__open: (Integer base_offset, nanoseconds now, [Integer, Integer] scope_and_issued, Policy policy) -> Journal
|
|
193
|
+
private def self.__check_policy: (Integer? max_bytes, Integer? max_records, nanoseconds? max_age,
|
|
194
|
+
Integer min_dead_per_mille) -> nil
|
|
195
|
+
private def self.__check_due: (roll_reason reason) -> nil
|
|
196
|
+
private def self.__check_rolled: (Integer sealed, Integer opened, Integer next_offset) -> nil
|
|
197
|
+
private def self.__check_reclaimed: (Integer segment, Integer revision, Integer bytes, Integer? replaced_by) -> nil
|
|
198
|
+
# Segment's id, revision, base_offset, records, then stored_records,
|
|
199
|
+
# live_records, bytes, opened_at.
|
|
200
|
+
private def self.__check_segment: ([Integer, Integer, Integer, Integer] head,
|
|
201
|
+
[Integer, Integer, Integer, nanoseconds] counts, segment_state state,
|
|
202
|
+
retention retention, Replacement? replacement) -> nil
|
|
203
|
+
|
|
204
|
+
private
|
|
205
|
+
|
|
206
|
+
# The Policy fields `policy` builds its value from, in order.
|
|
207
|
+
def __policy: () -> [Integer?, Integer?, nanoseconds?, Integer]
|
|
208
|
+
end
|
|
209
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: journal_machines
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.7.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Abdelkader Boudih
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: rb_sys
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0.9'
|
|
19
|
+
- - ">="
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: 0.9.130
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - "~>"
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '0.9'
|
|
29
|
+
- - ">="
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: 0.9.130
|
|
32
|
+
description: 'Decides when to roll a log segment, which sealed segments are worth
|
|
33
|
+
compacting, and when a replaced segment file may be deleted without losing what
|
|
34
|
+
a reader or checkpoint pin still needs. Metadata only: not a log writer, byte compactor
|
|
35
|
+
or recovery runtime.'
|
|
36
|
+
email:
|
|
37
|
+
- oss@seuros.com
|
|
38
|
+
executables: []
|
|
39
|
+
extensions:
|
|
40
|
+
- ext/journal_machines_native/extconf.rb
|
|
41
|
+
extra_rdoc_files: []
|
|
42
|
+
files:
|
|
43
|
+
- CHANGELOG.md
|
|
44
|
+
- Cargo.lock
|
|
45
|
+
- Cargo.toml
|
|
46
|
+
- LICENSE.txt
|
|
47
|
+
- README.md
|
|
48
|
+
- ext/journal_machines_native/core/CHANGELOG.md
|
|
49
|
+
- ext/journal_machines_native/core/Cargo.toml
|
|
50
|
+
- ext/journal_machines_native/core/README.md
|
|
51
|
+
- ext/journal_machines_native/core/src/checked.rs
|
|
52
|
+
- ext/journal_machines_native/core/src/lib.rs
|
|
53
|
+
- ext/journal_machines_native/core/src/pins.rs
|
|
54
|
+
- ext/journal_machines_native/core/src/policy.rs
|
|
55
|
+
- ext/journal_machines_native/core/src/refusal.rs
|
|
56
|
+
- ext/journal_machines_native/core/src/replace.rs
|
|
57
|
+
- ext/journal_machines_native/core/src/segment.rs
|
|
58
|
+
- ext/journal_machines_native/extconf.rb
|
|
59
|
+
- ext/journal_machines_native/ffi/Cargo.toml
|
|
60
|
+
- ext/journal_machines_native/ffi/extconf.rb
|
|
61
|
+
- ext/journal_machines_native/ffi/src/answers.rs
|
|
62
|
+
- ext/journal_machines_native/ffi/src/classes.rs
|
|
63
|
+
- ext/journal_machines_native/ffi/src/convert.rs
|
|
64
|
+
- ext/journal_machines_native/ffi/src/handles.rs
|
|
65
|
+
- ext/journal_machines_native/ffi/src/init.rs
|
|
66
|
+
- ext/journal_machines_native/ffi/src/lib.rs
|
|
67
|
+
- ext/journal_machines_native/ffi/src/values.rs
|
|
68
|
+
- lib/journal_machines.rb
|
|
69
|
+
- lib/journal_machines/version.rb
|
|
70
|
+
- sig/journal_machines.rbs
|
|
71
|
+
homepage: https://github.com/seuros/journal_machines
|
|
72
|
+
licenses:
|
|
73
|
+
- MIT
|
|
74
|
+
metadata:
|
|
75
|
+
source_code_uri: https://github.com/seuros/journal_machines
|
|
76
|
+
rubygems_mfa_required: 'true'
|
|
77
|
+
cargo_crate_name: journal_machines_native
|
|
78
|
+
cargo_manifest_path: ext/journal_machines_native/ffi/Cargo.toml
|
|
79
|
+
rdoc_options: []
|
|
80
|
+
require_paths:
|
|
81
|
+
- lib
|
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
|
+
requirements:
|
|
84
|
+
- - ">="
|
|
85
|
+
- !ruby/object:Gem::Version
|
|
86
|
+
version: 4.0.0
|
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
92
|
+
requirements: []
|
|
93
|
+
rubygems_version: 4.0.20
|
|
94
|
+
specification_version: 4
|
|
95
|
+
summary: 'Log segment metadata for Ruby: roll decisions, compaction candidates, pin-gated
|
|
96
|
+
reclaim'
|
|
97
|
+
test_files: []
|