File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77class EchoService
88 include Rubyists ::Leopard ::NatsApiServer
99
10+ config . logger = SemanticLogger [ :EchoService ]
1011 def initialize ( a_var : 1 )
1112 logger . info "EchoService initialized with a_var: #{ a_var } "
1213 end
1314
14- endpoint ( :echo ) { |msg | Success ( msg . data ) }
15- endpoint ( :echo_fail ) { |msg | Failure ( { failure : '*boom*' , data : msg . data } ) }
15+ endpoint ( :echo ) do |msg |
16+ data = msg . data
17+ logger . trace ( 'Received message' , data :)
18+ Success ( data )
19+ end
20+ endpoint ( :echo_fail ) do |msg |
21+ data = msg . data
22+ logger . trace ( 'Received message' , data :)
23+ Failure ( { failure : '*boom*' , data : msg . data } )
24+ end
1625end
1726
1827if __FILE__ == $PROGRAM_NAME
1928 SemanticLogger . default_level = :info
29+ SemanticLogger . add_signal_handler
2030 SemanticLogger . add_appender ( io : $stdout, formatter : :color )
2131 EchoService . run (
2232 nats_url : 'nats://localhost:4222' ,
@@ -25,6 +35,6 @@ def initialize(a_var: 1)
2535 version : '1.0.0' ,
2636 instance_args : { a_var : 2 } ,
2737 } ,
28- instances : 1 ,
38+ instances : ENV . fetch ( 'ECHO_INSTANCES' , '1' ) . to_i ,
2939 )
3040end
You can’t perform that action at this time.
0 commit comments