Sha256: b1d81de765291ca517742dc5ebcce22a0cb4d778689f2bd5ca726d43bad0e73e

Contents?: true

Size: 1.41 KB

Versions: 7

Compression:

Stored size: 1.41 KB

Contents

#
# This class will handle the sending of log group message to agent
#
module Stackify
  class AgentBaseSender < Worker

    # send_logs() Function to put the msg in the Worker
    def send_logs msgs, attempts = 3
      worker = Stackify::LogsSenderWorker.new('UnixSocketSender worker')
      task = send_logs_task attempts, msgs
      worker.async_perform ScheduleDelay.new, task
    end

    private

    def properties
      {
        success_condition: lambda { |result| result.try(:status) == 200 },
        limit: 1
      }.dup
    end

    def send_logs_task attempts = nil, msgs
      properties[:attempts] = attempts if attempts
      Stackify::ScheduleTask.new properties do
        data = gather_and_pack_data(msgs).to_json
        send_request data
      end
    end

    def gather_and_pack_data msgs
      details = Stackify::EnvDetails.instance.auth_info
      {
        'CDID' => details['DeviceID'],
        'CDAppID' => details['DeviceAppID'],
        'Logger' => 'Rails logger',
        'AppName' => details['AppName'],
        'AppNameID' => details['AppNameID'],
        'Env' => details['Env'],
        'EnvID' => details['EnvID'],
        'AppEnvID' => details['AppEnvID'],
        'ServerName' => details['DeviceName'],
        'Msgs' => msgs,
        'AppLoc' => details['AppLocation'],
        'Platform' => 'Ruby'
      }
    end

    def send_request log_group
      raise NotImplementedError
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
stackify-api-ruby-2.1.0 lib/stackify/agent_base_sender.rb
stackify-api-ruby-2.1.0.beta1 lib/stackify/agent_base_sender.rb
stackify-api-ruby-2.0.0 lib/stackify/agent_base_sender.rb
stackify-api-ruby-1.3.0.beta1 lib/stackify/agent_base_sender.rb
stackify-api-ruby-1.2.10 lib/stackify/agent_base_sender.rb
stackify-api-ruby-1.2.9 lib/stackify/agent_base_sender.rb
stackify-api-ruby-1.2.7 lib/stackify/agent_base_sender.rb