Class: Nonnative::Server

Inherits:
Runner
  • Object
show all
Defined in:
lib/nonnative/server.rb

Direct Known Subclasses

GRPCServer, HTTPServer

Instance Attribute Summary

Attributes inherited from Runner

#proxy

Instance Method Summary collapse

Methods inherited from Runner

#name

Constructor Details

#initialize(service) ⇒ Server

Returns a new instance of Server.



5
6
7
8
9
# File 'lib/nonnative/server.rb', line 5

def initialize(service)
  super

  @timeout = Nonnative::Timeout.new(service.timeout)
end

Instance Method Details

#startObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/nonnative/server.rb', line 11

def start
  unless thread
    proxy.start
    @thread = Thread.new { perform_start }

    wait_start
  end

  [object_id, true]
end

#stopObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/nonnative/server.rb', line 22

def stop
  if thread
    perform_stop
    thread.terminate
    proxy.stop

    @thread = nil
    wait_stop
  end

  object_id
end