Module: ZK::ForkHook

Extended by:
ForkHook
Includes:
Logger
Included in:
ForkHook
Defined in:
lib/zk/fork_hook.rb

Defined Under Namespace

Classes: ForkSubscription

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logger

#logger, wrapped_logger, wrapped_logger=

Instance Attribute Details

#hooksObject (readonly)

Returns the value of attribute hooks.



14
15
16
# File 'lib/zk/fork_hook.rb', line 14

def hooks
  @hooks
end

#mutexObject (readonly)

Returns the value of attribute mutex.



14
15
16
# File 'lib/zk/fork_hook.rb', line 14

def mutex
  @mutex
end

Class Method Details

.loggerObject



97
98
99
# File 'lib/zk/fork_hook.rb', line 97

def self.logger
  @logger ||= ::ZK.logger || Zookeeper::Logger::ForwardingLogger.for(::ZK::Logger.wrapped_logger, _zk_logger_name)
end

Instance Method Details

#after_fork_in_child(callable = nil, &blk) ⇒ Object

register a block that will be called after the fork happens in the child process



93
94
95
# File 'lib/zk/fork_hook.rb', line 93

def after_fork_in_child(callable=nil, &blk)
  register(:after_child, callable || blk)
end

#after_fork_in_parent(callable = nil, &blk) ⇒ Object

register a block that will be called after the fork happens in the parent process



88
89
90
# File 'lib/zk/fork_hook.rb', line 88

def after_fork_in_parent(callable=nil, &blk)
  register(:after_parent, callable || blk)
end

#prepare_for_fork(callable = nil, &blk) ⇒ Object

Register a block that will be called in the parent process before a fork() occurs



83
84
85
# File 'lib/zk/fork_hook.rb', line 83

def prepare_for_fork(callable=nil, &blk)
  register(:prepare, callable || blk)
end