Class: Textus::Operations
- Inherits:
-
Object
- Object
- Textus::Operations
- Defined in:
- lib/textus/operations.rb
Overview
Single canonical entrypoint for invoking application use-cases against a store. Public surface is flat — one method per use case:
ops = Textus::Operations.for(store, role: "agent")
ops.put(key, body: "...")
ops.get(key) # pure read
ops.get_or_refresh(key) # read + refresh-on-stale
ops.refresh(key) # synchronous worker refresh
ops.refresh_all(prefix: ..., zone: ...)
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Class Method Summary collapse
Instance Method Summary collapse
- #accept ⇒ Object
- #audit ⇒ Object
- #blame ⇒ Object
- #delete ⇒ Object
- #deps ⇒ Object
- #freshness ⇒ Object
-
#get ⇒ Object
reads.
- #get_or_refresh ⇒ Object
- #hook_context ⇒ Object
-
#initialize(ctx:, manifest:, file_store:, schemas:, audit_log:, bus:, root:, store:) ⇒ Operations
constructor
rubocop:disable Metrics/ParameterLists.
- #list ⇒ Object
- #mv ⇒ Object
- #policy_explain ⇒ Object
- #publish ⇒ Object
- #published ⇒ Object
-
#put ⇒ Object
writes.
- #rdeps ⇒ Object
-
#refresh(key) ⇒ Object
refresh.
- #refresh_all ⇒ Object
- #reject ⇒ Object
- #schema_envelope ⇒ Object
- #stale ⇒ Object
- #uid ⇒ Object
- #validate_all ⇒ Object
- #where ⇒ Object
-
#with_role(role) ⇒ Object
rubocop:enable Metrics/ParameterLists.
Constructor Details
#initialize(ctx:, manifest:, file_store:, schemas:, audit_log:, bus:, root:, store:) ⇒ Operations
rubocop:disable Metrics/ParameterLists
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/textus/operations.rb', line 28 def initialize(ctx:, manifest:, file_store:, schemas:, audit_log:, bus:, root:, store:) @ctx = ctx @manifest = manifest @file_store = file_store @schemas = schemas @audit_log = audit_log @bus = bus @root = root @store = store @authorizer = Textus::Domain::Authorizer.new(manifest: @manifest) end |
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
25 26 27 |
# File 'lib/textus/operations.rb', line 25 def ctx @ctx end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
25 26 27 |
# File 'lib/textus/operations.rb', line 25 def store @store end |
Class Method Details
.for(store, role: Role::DEFAULT, correlation_id: nil, dry_run: false) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/textus/operations.rb', line 12 def self.for(store, role: Role::DEFAULT, correlation_id: nil, dry_run: false) new( ctx: Application::Context.build(role: role, correlation_id: correlation_id, dry_run: dry_run), manifest: store.manifest, file_store: store.file_store, schemas: store.schemas, audit_log: store.audit_log, bus: store.bus, root: store.root, store: store, ) end |
Instance Method Details
#accept ⇒ Object
76 77 78 79 80 81 |
# File 'lib/textus/operations.rb', line 76 def accept(...) Application::Writes::Accept.new( ctx: @ctx, manifest: @manifest, file_store: @file_store, schemas: @schemas, envelope_io: envelope_io, bus: @bus, authorizer: @authorizer, hook_context: hook_context ).call(...) end |
#audit ⇒ Object
118 |
# File 'lib/textus/operations.rb', line 118 def audit(...) = Application::Reads::Audit.new(manifest: @manifest, root: @root).call(...) |
#blame ⇒ Object
119 |
# File 'lib/textus/operations.rb', line 119 def blame(...) = Application::Reads::Blame.new(manifest: @manifest, root: @root).call(...) |
#delete ⇒ Object
62 63 64 65 66 67 |
# File 'lib/textus/operations.rb', line 62 def delete(...) Application::Writes::Delete.new( ctx: @ctx, manifest: @manifest, envelope_io: envelope_io, bus: @bus, authorizer: @authorizer, hook_context: hook_context ).call(...) end |
#deps ⇒ Object
114 |
# File 'lib/textus/operations.rb', line 114 def deps(...) = Application::Reads::Deps.new(manifest: @manifest).call(...) |
#freshness ⇒ Object
121 |
# File 'lib/textus/operations.rb', line 121 def freshness(...) = Application::Reads::Freshness.new(ctx: @ctx, manifest: @manifest, file_store: @file_store).call(...) |
#get ⇒ Object
reads
98 99 100 |
# File 'lib/textus/operations.rb', line 98 def get(...) Application::Reads::Get.new(ctx: @ctx, manifest: @manifest, file_store: @file_store).call(...) end |
#get_or_refresh ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/textus/operations.rb', line 102 def get_or_refresh(...) Application::Reads::GetOrRefresh.new( manifest: @manifest, get: Application::Reads::Get.new(ctx: @ctx, manifest: @manifest, file_store: @file_store), orchestrator: orchestrator, ).call(...) end |
#hook_context ⇒ Object
50 51 52 |
# File 'lib/textus/operations.rb', line 50 def hook_context @hook_context ||= Textus::Hooks::Context.new(ops: self) end |
#list ⇒ Object
110 |
# File 'lib/textus/operations.rb', line 110 def list(...) = Application::Reads::List.new(manifest: @manifest).call(...) |
#mv ⇒ Object
69 70 71 72 73 74 |
# File 'lib/textus/operations.rb', line 69 def mv(...) Application::Writes::Mv.new( ctx: @ctx, manifest: @manifest, envelope_io: envelope_io, bus: @bus, authorizer: @authorizer, hook_context: hook_context ).call(...) end |
#policy_explain ⇒ Object
120 |
# File 'lib/textus/operations.rb', line 120 def policy_explain(...) = Application::Reads::PolicyExplain.new(manifest: @manifest).call(...) |
#publish ⇒ Object
90 91 92 93 94 95 |
# File 'lib/textus/operations.rb', line 90 def publish(...) Application::Writes::Publish.new( ctx: @ctx, manifest: @manifest, file_store: @file_store, bus: @bus, root: @root, store: @store, hook_context: hook_context ).call(...) end |
#published ⇒ Object
116 |
# File 'lib/textus/operations.rb', line 116 def published(...) = Application::Reads::Published.new(manifest: @manifest).call(...) |
#put ⇒ Object
writes
55 56 57 58 59 60 |
# File 'lib/textus/operations.rb', line 55 def put(...) Application::Writes::Put.new( ctx: @ctx, manifest: @manifest, envelope_io: envelope_io, bus: @bus, authorizer: @authorizer, hook_context: hook_context ).call(...) end |
#rdeps ⇒ Object
115 |
# File 'lib/textus/operations.rb', line 115 def rdeps(...) = Application::Reads::Rdeps.new(manifest: @manifest).call(...) |
#refresh(key) ⇒ Object
refresh
130 |
# File 'lib/textus/operations.rb', line 130 def refresh(key) = refresh_worker.run(key) |
#refresh_all ⇒ Object
132 133 134 135 136 137 |
# File 'lib/textus/operations.rb', line 132 def refresh_all(**) Application::Refresh::All.new( ctx: @ctx, manifest: @manifest, envelope_io: envelope_io, bus: @bus, store: @store, authorizer: @authorizer, hook_context: hook_context ).call(**) end |
#reject ⇒ Object
83 84 85 86 87 88 |
# File 'lib/textus/operations.rb', line 83 def reject(...) Application::Writes::Reject.new( ctx: @ctx, manifest: @manifest, file_store: @file_store, envelope_io: envelope_io, bus: @bus, authorizer: @authorizer, hook_context: hook_context ).call(...) end |
#schema_envelope ⇒ Object
113 |
# File 'lib/textus/operations.rb', line 113 def schema_envelope(...) = Application::Reads::SchemaEnvelope.new(manifest: @manifest, schemas: @schemas).call(...) |
#stale ⇒ Object
117 |
# File 'lib/textus/operations.rb', line 117 def stale(...) = Application::Reads::Stale.new(manifest: @manifest).call(...) |
#uid ⇒ Object
112 |
# File 'lib/textus/operations.rb', line 112 def uid(...) = Application::Reads::Uid.new(ctx: @ctx, manifest: @manifest, file_store: @file_store).call(...) |
#validate_all ⇒ Object
123 124 125 126 127 |
# File 'lib/textus/operations.rb', line 123 def validate_all(...) Application::Reads::ValidateAll.new( ctx: @ctx, manifest: @manifest, file_store: @file_store, schemas: @schemas, audit_log: @audit_log, ).call(...) end |
#where ⇒ Object
111 |
# File 'lib/textus/operations.rb', line 111 def where(...) = Application::Reads::Where.new(manifest: @manifest).call(...) |
#with_role(role) ⇒ Object
rubocop:enable Metrics/ParameterLists
41 42 43 44 45 46 47 48 |
# File 'lib/textus/operations.rb', line 41 def with_role(role) self.class.new( ctx: @ctx.with_role(role), manifest: @manifest, file_store: @file_store, schemas: @schemas, audit_log: @audit_log, bus: @bus, root: @root, store: @store ) end |