Class: VCAP::Spec::ForkedComponent::NatsServer

Inherits:
Base
  • Object
show all
Defined in:
lib/vcap/spec/forked_component/nats_server.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#cmd, #daemon, #name, #output_basedir, #pid, #pid_filename, #reopen_stdio

Instance Method Summary collapse

Methods inherited from Base

#running?, #start, #stop, #wait_ready

Constructor Details

#initialize(pid_filename, port, output_basedir = 'tmp') ⇒ NatsServer

Returns a new instance of NatsServer.



17
18
19
20
21
22
23
# File 'lib/vcap/spec/forked_component/nats_server.rb', line 17

def initialize(pid_filename, port, output_basedir='tmp')
  cmd = "ruby -S bundle exec nats-server -p #{port} -P #{pid_filename} -V -D"
  super(cmd, 'nats', output_basedir, pid_filename)
  @port = port
  @uri  = "nats://127.0.0.1:#{@port}"
  @parsed_uri = URI.parse(@uri)
end

Instance Attribute Details

#parsed_uriObject (readonly)

Returns the value of attribute parsed_uri.



15
16
17
# File 'lib/vcap/spec/forked_component/nats_server.rb', line 15

def parsed_uri
  @parsed_uri
end

#portObject (readonly)

Returns the value of attribute port.



15
16
17
# File 'lib/vcap/spec/forked_component/nats_server.rb', line 15

def port
  @port
end

#uriObject (readonly)

Returns the value of attribute uri.



15
16
17
# File 'lib/vcap/spec/forked_component/nats_server.rb', line 15

def uri
  @uri
end

Instance Method Details

#ready?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/vcap/spec/forked_component/nats_server.rb', line 25

def ready?
  running? && NATS.server_running?(@parsed_uri)
end