module Stackify
This class will handle the sending of log group message to agent
This class will handle the sending of log messages to agent using http request
This class will handle the sending of log messages to unix domain socket
Constants
- INTERNAL_LOG_PREFIX
- LogGroup
- MODES
- STATUSES
- TRANSPORT
- VERSION
Attributes
config[W]
Public Class Methods
add_dependant_worker(worker)
click to toggle source
# File lib/stackify-api-ruby.rb, line 105 def add_dependant_worker worker @workers << worker end
agent_client()
click to toggle source
# File lib/stackify-api-ruby.rb, line 74 def agent_client @agent_client ||= Stackify::AgentClient.new end
alive_adding_msg_workers()
click to toggle source
# File lib/stackify-api-ruby.rb, line 97 def alive_adding_msg_workers @workers.select{ |w| w.alive? && w.type == :add_msg } end
configuration()
click to toggle source
# File lib/stackify-api-ruby.rb, line 47 def configuration @config ||= Stackify::Configuration.new end
delete_worker(worker)
click to toggle source
# File lib/stackify-api-ruby.rb, line 101 def delete_worker worker @workers.delete worker end
get_transport()
click to toggle source
# File lib/stackify-api-ruby.rb, line 78 def get_transport @logger_client.get_transport end
internal_log(level, msg)
click to toggle source
# File lib/stackify-api-ruby.rb, line 117 def internal_log level, msg Stackify.logger.send(level.downcase.to_sym, Stackify::INTERNAL_LOG_PREFIX){ msg } end
is_valid?()
click to toggle source
# File lib/stackify-api-ruby.rb, line 180 def is_valid? configuration.is_valid? end
log_internal_error(msg)
click to toggle source
# File lib/stackify-api-ruby.rb, line 113 def log_internal_error msg Stackify.logger.error (::Stackify::INTERNAL_LOG_PREFIX){ msg } end
logger()
click to toggle source
# File lib/stackify-api-ruby.rb, line 86 def logger self.configuration.logger end
logger_client()
click to toggle source
# File lib/stackify-api-ruby.rb, line 70 def logger_client @logger_client ||= Stackify::LoggerClient.new end
make_remained_job()
click to toggle source
# File lib/stackify-api-ruby.rb, line 175 def make_remained_job @status = STATUSES[:terminating] Stackify.msgs_queue.push_remained_msgs end
msgs_queue()
click to toggle source
# File lib/stackify-api-ruby.rb, line 66 def msgs_queue @msgs_queue ||= Stackify::MsgsQueue.new end
run()
click to toggle source
# File lib/stackify-api-ruby.rb, line 121 def run Stackify::Utils.is_api_enabled Stackify.internal_log :info, "Stackify.run() transportType: #{Stackify.configuration.transport} | API version: #{Stackify::VERSION} | Ruby version: #{RUBY_VERSION}" if Stackify.configuration.api_enabled if Stackify.is_valid? # check transport types case Stackify.configuration.transport when Stackify::DEFAULT if Stackify.is_valid? at_exit { make_remained_job } t1 = Thread.new { Stackify.authorize } case Stackify.configuration.mode when MODES[:both] t2 = start_logging t3 = start_metrics when MODES[:logging] t2 = start_logging when MODES[:metrics] t3 = start_metrics end t1.join t3.join if t3 else Stackify.log_internal_error "Stackify is not properly configured! Errors: #{Stackify.configuration.errors}" end when Stackify::UNIX_SOCKET, Stackify::AGENT_HTTP case Stackify.configuration.mode when MODES[:logging] start_logging when MODES[:both] start_logging start_metrics when MODES[:metrics] start_metrics end else Stackify.log_internal_error "Stackify is not properly configured! Errors: #{Stackify.configuration.errors}" end end end end
send_unix_socket()
click to toggle source
# File lib/stackify-api-ruby.rb, line 82 def send_unix_socket @unix_socket ||= Stackify::UnixSocketSender.new end
setup() { |configuration| ... }
click to toggle source
# File lib/stackify-api-ruby.rb, line 51 def setup @workers = [] yield(configuration) if block_given? configuration.validate_transport_type if configuration.is_valid? @status = STATUSES[:working] else msg = "Stackify's configuration is not valid!" configuration.errors.each do |error_msg| msg += "\n" + error_msg end raise msg end end
shutdown_all(caller_obj=nil)
click to toggle source
# File lib/stackify-api-ruby.rb, line 90 def shutdown_all caller_obj=nil Stackify.status = Stackify::STATUSES[:terminating] @workers.each do |worker| worker.shutdown! unless worker.equal? caller_obj end end
start_logging()
click to toggle source
# File lib/stackify-api-ruby.rb, line 163 def start_logging msgs_queue end
start_metrics()
click to toggle source
# File lib/stackify-api-ruby.rb, line 167 def start_metrics Thread.new { Stackify::Metrics.metrics_client.start } end
status()
click to toggle source
# File lib/stackify-api-ruby.rb, line 109 def status @status end
status=(status)
click to toggle source
# File lib/stackify-api-ruby.rb, line 196 def status= status if STATUSES.has_value? status @status = status else raise "method 'status=' should get one of arguments #{STATUSES.values}, not a #{status}" end end
terminated?()
click to toggle source
# File lib/stackify-api-ruby.rb, line 188 def terminated? @status == STATUSES[:terminated] end
terminating?()
click to toggle source
# File lib/stackify-api-ruby.rb, line 184 def terminating? @status == STATUSES[:terminating] end
workers()
click to toggle source
# File lib/stackify-api-ruby.rb, line 171 def workers @workers end
working?()
click to toggle source
# File lib/stackify-api-ruby.rb, line 192 def working? @status == STATUSES[:working] end