Class: Textus::Operations

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#ctxObject (readonly)

Returns the value of attribute ctx.



25
26
27
# File 'lib/textus/operations.rb', line 25

def ctx
  @ctx
end

#storeObject (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

#acceptObject



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

#auditObject



118
# File 'lib/textus/operations.rb', line 118

def audit(...)           = Application::Reads::Audit.new(manifest: @manifest, root: @root, audit_log: @audit_log).call(...)

#blameObject



119
# File 'lib/textus/operations.rb', line 119

def blame(...)           = Application::Reads::Blame.new(manifest: @manifest, root: @root).call(...)

#deleteObject



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

#depsObject



114
# File 'lib/textus/operations.rb', line 114

def deps(...)            = Application::Reads::Deps.new(manifest: @manifest).call(...)

#freshnessObject



121
# File 'lib/textus/operations.rb', line 121

def freshness(...)       = Application::Reads::Freshness.new(ctx: @ctx, manifest: @manifest, file_store: @file_store).call(...)

#getObject

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_refreshObject



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_contextObject



50
51
52
# File 'lib/textus/operations.rb', line 50

def hook_context
  @hook_context ||= Textus::Hooks::Context.new(ops: self)
end

#listObject



110
# File 'lib/textus/operations.rb', line 110

def list(...)            = Application::Reads::List.new(manifest: @manifest).call(...)

#mvObject



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_explainObject



120
# File 'lib/textus/operations.rb', line 120

def policy_explain(...)  = Application::Reads::PolicyExplain.new(manifest: @manifest).call(...)

#publishObject



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

#publishedObject



116
# File 'lib/textus/operations.rb', line 116

def published(...)       = Application::Reads::Published.new(manifest: @manifest).call(...)

#pulseObject



123
124
125
126
127
128
# File 'lib/textus/operations.rb', line 123

def pulse(...)
  Application::Reads::Pulse.new(
    ctx: @ctx, manifest: @manifest, file_store: @file_store,
    audit_log: @audit_log, root: @root, store: @store
  ).call(...)
end

#putObject

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

#rdepsObject



115
# File 'lib/textus/operations.rb', line 115

def rdeps(...)           = Application::Reads::Rdeps.new(manifest: @manifest).call(...)

#refresh(key) ⇒ Object

refresh



137
# File 'lib/textus/operations.rb', line 137

def refresh(key) = refresh_worker.run(key)

#refresh_allObject



139
140
141
142
143
144
# File 'lib/textus/operations.rb', line 139

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

#rejectObject



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_envelopeObject



113
# File 'lib/textus/operations.rb', line 113

def schema_envelope(...) = Application::Reads::SchemaEnvelope.new(manifest: @manifest, schemas: @schemas).call(...)

#staleObject



117
# File 'lib/textus/operations.rb', line 117

def stale(...)           = Application::Reads::Stale.new(manifest: @manifest).call(...)

#uidObject



112
# File 'lib/textus/operations.rb', line 112

def uid(...)             = Application::Reads::Uid.new(ctx: @ctx, manifest: @manifest, file_store: @file_store).call(...)

#validate_allObject



130
131
132
133
134
# File 'lib/textus/operations.rb', line 130

def validate_all(...)
  Application::Reads::ValidateAll.new(
    ctx: @ctx, manifest: @manifest, file_store: @file_store, schemas: @schemas, audit_log: @audit_log,
  ).call(...)
end

#whereObject



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