Module: Shifty::PolicyDeclarable

Included in:
Gang, Worker
Defined in:
lib/shifty/policy.rb

Overview

Shared by Worker and Gang: declares a pipeline-level policy default on every node reachable upstream through the supply chain. A worker's own policy declaration (its contract) always wins over the pipeline default.

Instance Method Summary collapse

Instance Method Details

#freeze!Object

Locks the assembled topology: "the pipeline you composed is the pipeline that runs" becomes a guarantee. Rewiring (supply=, Gang append/roster mutation) raises FrozenError afterward. Worker closure/context state stays mutable — only the topology freezes.

Call this on the pipeline's TAIL: like with_policy, it walks the supply chain upstream, so freezing a mid-chain node leaves everything downstream of it mutable. And use this, not the bare Object#freeze — freeze! first materializes each node's lazy task and Fiber; a bare freeze skips that and the first shift would raise FrozenError from deep inside the worker.



23
24
25
26
# File 'lib/shifty/policy.rb', line 23

def freeze!
  each_upstream_node { |node| node.freeze_topology_node! }
  self
end

#with_policy(policy_name) ⇒ Object



6
7
8
9
10
# File 'lib/shifty/policy.rb', line 6

def with_policy(policy_name)
  policy_name = Policy.validate!(policy_name)
  each_upstream_node { |node| node.pipeline_policy = policy_name }
  self
end