Class: Textus::Store
- Inherits:
-
Object
- Object
- Textus::Store
- Defined in:
- lib/textus/store.rb,
lib/textus/store/cursor.rb,
lib/textus/store/layout.rb,
lib/textus/store/container.rb,
lib/textus/store/freshness.rb,
lib/textus/store/jobs/base.rb,
lib/textus/store/jobs/plan.rb,
lib/textus/store/jobs/index.rb,
lib/textus/store/jobs/queue.rb,
lib/textus/store/jobs/sweep.rb,
lib/textus/store/jobs/worker.rb,
lib/textus/store/entry/reader.rb,
lib/textus/store/entry/writer.rb,
lib/textus/store/index/lookup.rb,
lib/textus/store/jobs/planner.rb,
lib/textus/store/envelope/meta.rb,
lib/textus/store/index/builder.rb,
lib/textus/store/jobs/registry.rb,
lib/textus/store/jobs/retention.rb,
lib/textus/store/jobs/materialize.rb,
lib/textus/store/freshness/verdict.rb,
lib/textus/store/freshness/evaluator.rb,
lib/textus/store/jobs/retention/base.rb,
lib/textus/store/jobs/retention/sweep.rb,
lib/textus/store/freshness/ttl_evaluator.rb,
lib/textus/store/freshness/drift_detector.rb
Defined Under Namespace
Modules: Entry, Envelope, Freshness, Index, Jobs Classes: Container, Cursor, Layout
Instance Attribute Summary collapse
-
#container ⇒ Object
readonly
Returns the value of attribute container.
-
#contract_etag ⇒ Object
readonly
Returns the value of attribute contract_etag.
-
#correlation_id ⇒ Object
readonly
Returns the value of attribute correlation_id.
-
#cursor ⇒ Object
readonly
Returns the value of attribute cursor.
-
#propose_lane ⇒ Object
readonly
Returns the value of attribute propose_lane.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Class Method Summary collapse
Instance Method Summary collapse
- #advance_cursor(new_cursor) ⇒ Object
- #check_etag!(observed_etag) ⇒ Object
- #dry_run? ⇒ Boolean
-
#initialize(root, role: Value::Role::DEFAULT, correlation_id: nil, dry_run: false, container: nil) ⇒ Store
constructor
A new instance of Store.
- #with_correlation_id(cid) ⇒ Object
- #with_role(new_role) ⇒ Object
Constructor Details
#initialize(root, role: Value::Role::DEFAULT, correlation_id: nil, dry_run: false, container: nil) ⇒ Store
Returns a new instance of Store.
42 43 44 45 46 47 48 49 |
# File 'lib/textus/store.rb', line 42 def initialize(root, role: Value::Role::DEFAULT, correlation_id: nil, dry_run: false, container: nil) @root = File.(root) @container = container || build_container(@root) @role = role.to_s @correlation_id = correlation_id || SecureRandom.uuid @dry_run = dry_run build_session! end |
Instance Attribute Details
#container ⇒ Object (readonly)
Returns the value of attribute container.
5 6 7 |
# File 'lib/textus/store.rb', line 5 def container @container end |
#contract_etag ⇒ Object (readonly)
Returns the value of attribute contract_etag.
5 6 7 |
# File 'lib/textus/store.rb', line 5 def contract_etag @contract_etag end |
#correlation_id ⇒ Object (readonly)
Returns the value of attribute correlation_id.
5 6 7 |
# File 'lib/textus/store.rb', line 5 def correlation_id @correlation_id end |
#cursor ⇒ Object (readonly)
Returns the value of attribute cursor.
5 6 7 |
# File 'lib/textus/store.rb', line 5 def cursor @cursor end |
#propose_lane ⇒ Object (readonly)
Returns the value of attribute propose_lane.
5 6 7 |
# File 'lib/textus/store.rb', line 5 def propose_lane @propose_lane end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
5 6 7 |
# File 'lib/textus/store.rb', line 5 def role @role end |
Class Method Details
.discover(start_dir = Dir.pwd, root: nil) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/textus/store.rb', line 11 def self.discover(start_dir = Dir.pwd, root: nil) explicit = root || ENV.fetch("TEXTUS_ROOT", nil) return discover_explicit(explicit) if explicit ascend_for_store(File.(start_dir)) || raise(IoError.new("no .textus directory found from #{start_dir}")) end |
Instance Method Details
#advance_cursor(new_cursor) ⇒ Object
61 62 63 64 65 |
# File 'lib/textus/store.rb', line 61 def advance_cursor(new_cursor) dup.tap do |s| s.instance_variable_set(:@cursor, new_cursor) end end |
#check_etag!(observed_etag) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/textus/store.rb', line 67 def check_etag!(observed_etag) return if observed_etag == @contract_etag raise Textus::ContractDrift.new( "contract changed (manifest/hooks/schemas were #{short_etag(@contract_etag)}, " \ "now #{short_etag(observed_etag)}); re-run boot", ) end |
#dry_run? ⇒ Boolean
51 |
# File 'lib/textus/store.rb', line 51 def dry_run? = @dry_run |
#with_correlation_id(cid) ⇒ Object
57 58 59 |
# File 'lib/textus/store.rb', line 57 def with_correlation_id(cid) _rebuild(correlation_id: cid) end |
#with_role(new_role) ⇒ Object
53 54 55 |
# File 'lib/textus/store.rb', line 53 def with_role(new_role) _rebuild(role: new_role) end |