Class: Application

Inherits:
Object
  • Object
show all
Extended by:
ApplicationConfiguration
Defined in:
lib/sample_core_api.rb

Instance Method Summary collapse

Methods included from ApplicationConfiguration

config, config_consul, config_rest, random_name

Constructor Details

#initialize(rests = [], config = {}) ⇒ Application

Returns a new instance of Application.



14
15
16
17
# File 'lib/sample_core_api.rb', line 14

def initialize(rests=[], config={})
  @config = config
  @rests = rests
end

Instance Method Details

#init_rest_serviceObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sample_core_api.rb', line 19

def init_rest_service
  rests = @rests
  return Sinatra.new {
    # before '/*' do
    #   puts "set local thread"
    #   # Thread.current[:user] = "ltran"
    # end
    rests.each {|a| use a}
    not_found do
      JSON RestService.error_response('EntityNotFound')
    end
  }
end

#startObject



33
34
35
36
37
38
# File 'lib/sample_core_api.rb', line 33

def start
  puts 'start'
  Container["consul_service"].start
  Container["cassandra_service"].start
  init_rest_service
end

#stopObject



40
41
42
43
# File 'lib/sample_core_api.rb', line 40

def stop
  Container["consul_service"].stop
  Container["cassandra_service"].stop
end