Class: Stackify::UnixSocketSender
- Inherits:
-
AgentBaseSender
- Object
- Worker
- AgentBaseSender
- Stackify::UnixSocketSender
- Defined in:
- lib/stackify/unix_socket_sender.rb
Instance Attribute Summary
Attributes inherited from Worker
Instance Method Summary collapse
-
#send_request(log_group) ⇒ Object
send_request() This function will send http request via unix domain socket return Object Return an object message.
Methods inherited from AgentBaseSender
Methods inherited from Worker
#alive?, #async_perform, #backtrace, #id, #initialize, #perform, #shutdown!, #status
Constructor Details
This class inherits a constructor from Stackify::Worker
Instance Method Details
#send_request(log_group) ⇒ Object
send_request() This function will send http request via unix domain socket return Object Return an object message
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/stackify/unix_socket_sender.rb', line 13 def send_request log_group begin client = NetX::HTTPUnix.new('unix://' + Stackify.configuration.unix_socket_path) req = Net::HTTP::Post.new(Stackify.configuration.agent_log_url) req.set_content_type('application/json') req.body = log_group response = client.request(req) Stackify.internal_log :debug, "[UnixSocketSender] status_code = #{response.code}" if response.code.to_i == 200 Stackify.internal_log :debug, "[UnixSocketSender]: Successfully send message via unix domain socket." return OpenStruct.new({status: 200, msg: 'OK'}) else Stackify.internal_log :debug, "[UnixSocketSender] Sending failed." return OpenStruct.new({status: 500, msg: 'Not OK'}) end rescue => exception Stackify.log_internal_error "[UnixSocketSender] send_logs() Error: #{exception}" return OpenStruct.new({status: 500, msg: exception}) end end |