Class: Textus::Store::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/store/container.rb

Defined Under Namespace

Classes: Coordination, Infrastructure

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(infra, coord) ⇒ Container

Returns a new instance of Container.



11
12
13
14
# File 'lib/textus/store/container.rb', line 11

def initialize(infra, coord)
  @infra = infra
  @coord = coord
end

Instance Attribute Details

#coordObject (readonly)

Returns the value of attribute coord.



16
17
18
# File 'lib/textus/store/container.rb', line 16

def coord
  @coord
end

#infraObject (readonly)

Returns the value of attribute infra.



16
17
18
# File 'lib/textus/store/container.rb', line 16

def infra
  @infra
end

#pipelineObject (readonly)

Returns the value of attribute pipeline.



16
17
18
# File 'lib/textus/store/container.rb', line 16

def pipeline
  @pipeline
end

#readerObject (readonly)

Returns the value of attribute reader.



16
17
18
# File 'lib/textus/store/container.rb', line 16

def reader
  @reader
end

#writerObject (readonly)

Returns the value of attribute writer.



16
17
18
# File 'lib/textus/store/container.rb', line 16

def writer
  @writer
end

Class Method Details

.attribute_namesObject



7
8
9
# File 'lib/textus/store/container.rb', line 7

def self.attribute_names
  @attribute_names ||= [:root] + Infrastructure.members + Coordination.members
end

.build(infra, coord_seed) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/textus/store/container.rb', line 42

def self.build(infra, coord_seed)
  coord = Coordination.new(
    manifest: coord_seed.manifest,
    workflows: coord_seed.workflows,
    pipeline: nil,
  )
  container = new(infra, coord)
  pipeline = build_pipeline(container)
  reader   = Textus::Store::Entry::Reader.from(container: container)
  writer   = create_writer_factory(container)
  container.wire!(pipeline: pipeline, reader: reader, writer: writer)
end

.create_writer_factory(container) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/textus/store/container.rb', line 150

def self.create_writer_factory(container)
  lambda do |call|
    Textus::Store::Entry::Writer.new(
      file_store: container.file_store,
      manifest: container.manifest,
      schemas: container.schemas,
      audit_log: container.audit_log,
      call: call,
      reader: container.reader,
      layout: container.layout,
    )
  end
end

.freshness_evaluator(container) ⇒ Object



164
165
166
167
168
169
170
# File 'lib/textus/store/container.rb', line 164

def self.freshness_evaluator(container)
  Store::Freshness::TtlEvaluator.new(
    manifest: container.manifest,
    file_stat: Textus::Port::Storage::FileStat.new,
    clock: Textus::Port::Clock.new,
  )
end

.orchestration_for(container) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/textus/store/container.rb', line 55

def self.orchestration_for(container)
  Orchestration.new(
    list_keys: Handlers::Read::ListKeys.new(manifest: container.manifest, job_store: container.job_store),
    move_key: Handlers::Write::MoveKey.new(container: container, manifest: container.manifest),
    delete_key: Handlers::Write::DeleteKey.new(container: container),
    audit_entries: Handlers::Read::AuditEntries.new(manifest: container.manifest, audit_log: container.audit_log),
  )
end

Instance Method Details

#rootObject



18
19
20
# File 'lib/textus/store/container.rb', line 18

def root
  @infra.layout.root
end

#wire!(pipeline:, reader:, writer:) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/textus/store/container.rb', line 30

def wire!(pipeline:, reader:, writer:)
  @pipeline = pipeline
  @reader   = reader
  @writer   = writer
  @coord    = Coordination.new(
    manifest: @coord.manifest,
    workflows: @coord.workflows,
    pipeline: pipeline,
  )
  self
end