Class: Riser::DRbServiceFront

Inherits:
Object
  • Object
show all
Defined in:
lib/riser/services.rb

Instance Method Summary collapse

Constructor Details

#initializeDRbServiceFront

Returns a new instance of DRbServiceFront.



13
14
15
16
# File 'lib/riser/services.rb', line 13

def initialize
  @mutex = Thread::Mutex.new
  @services = {}
end

Instance Method Details

#add_service(name, front) ⇒ Object



22
23
24
25
# File 'lib/riser/services.rb', line 22

def add_service(name, front)
  @services[name] = DRbService.new(front, DRbService::NO_CALL, DRbService::NO_CALL, DRbService::NO_CALL)
  nil
end

#apply_at_forkObject



41
42
43
44
45
46
47
# File 'lib/riser/services.rb', line 41

def apply_at_fork
  @services.each_value do |service|
    service.at_fork.call(service.front)
  end

  nil
end

#apply_service_hooksObject



67
68
69
70
71
# File 'lib/riser/services.rb', line 67

def apply_service_hooks
  apply_service_hooks_by_name(0, @services.keys) {
    yield
  }
end

#at_fork(name, &block) ⇒ Object

:yields: service_front



27
28
29
30
# File 'lib/riser/services.rb', line 27

def at_fork(name, &block)   # :yields: service_front
  @services[name].at_fork = block
  nil
end

#get_service(name) ⇒ Object



73
74
75
76
77
# File 'lib/riser/services.rb', line 73

def get_service(name)
  @mutex.synchronize{
    @services[name].ref ||= DRbObject.new(@services[name].front)
  }
end

#pingObject



18
19
20
# File 'lib/riser/services.rb', line 18

def ping
  yield
end

#postprocess(name, &block) ⇒ Object

:yields: service_front



36
37
38
39
# File 'lib/riser/services.rb', line 36

def postprocess(name, &block) # :yields: service_front
  @services[name].postprocess = block
  nil
end

#preprocess(name, &block) ⇒ Object

:yields: service_front



32
33
34
# File 'lib/riser/services.rb', line 32

def preprocess(name, &block) # :yields: service_front
  @services[name].preprocess = block
end