Module: Undertow

Defined in:
lib/undertow.rb,
lib/undertow/dsl.rb,
lib/undertow/buffer.rb,
lib/undertow/railtie.rb,
lib/undertow/version.rb,
lib/undertow/registry.rb,
lib/undertow/drain_job.rb,
lib/undertow/trackable.rb,
lib/undertow/configuration.rb

Defined Under Namespace

Modules: Buffer, DSL, Registry, Trackable Classes: Configuration, DrainJob, Railtie

Constant Summary collapse

VERSION =
'0.1.0'

Class Method Summary collapse

Class Method Details

.configurationObject



21
22
23
# File 'lib/undertow.rb', line 21

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



17
18
19
# File 'lib/undertow.rb', line 17

def configure
  yield configuration
end

.tickObject

Called from the host application’s scheduler on each tick. Checks for pending work, acquires the drain lock, and enqueues DrainJob — no other wiring required:

every(1.second, 'undertow') { Undertow.tick }


45
46
47
48
49
50
# File 'lib/undertow.rb', line 45

def tick
  return unless Buffer.pending?
  return unless Buffer.acquire_drain_lock

  DrainJob.perform_later
end

.tracking_disabled?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/undertow.rb', line 35

def tracking_disabled?
  Thread.current[:undertow_disabled]
end

.without_trackingObject

Suppress all buffer pushes inside the block. Useful in tests and data migrations where dependency callbacks should not fire.



27
28
29
30
31
32
33
# File 'lib/undertow.rb', line 27

def without_tracking
  previous = Thread.current[:undertow_disabled]
  Thread.current[:undertow_disabled] = true
  yield
ensure
  Thread.current[:undertow_disabled] = previous
end