Skip to content

StoneCypher/atom-ruby

Repository files navigation

this was a server product that was shut down years ago

security holes are building up and i don't feel like fixing them because there's nothing to connect to

don't use this code






ironSource.atom SDK for Ruby

License Build status Coverage Status Docs

Atom-Ruby is the official ironSource.atom SDK for the Ruby programming language.

Installation

$ gem install iron_source_atom-1.1.0.gem

You may use SDK in two different ways:

  1. High level Tracker - contains in-memory storage and tracks events based on certain parameters.
  2. Low level - contains 2 methods: putEvent() and putEvents() to send 1 event or a batch respectively.

Tracker usage

require 'thread'
require 'json'
require 'iron_source_atom'

class TestTracker

def self.test_multitread
    url = "http://track.atom-data.io/"
    atom_tracker = IronSourceAtom::Tracker.new
    atom_tracker.auth = ""
    a=0
    run_example = true
    (0..5).each do |int|
      Thread.new do
        begin
          while run_example
            data = {
                id: a += 1,
                message: "#{int}Thread_array_data"
            }.to_json
            atom_tracker.track(data, "ibtest")
            puts "send data #{data}"
            sleep(0.05)
            if a > 100
              run_example = false
            end
          end
        end
      end
    end
    sleep 30
  end
  
  test_multitread
  
end

The Tracker process:

You can use track() method in order to track the events to an Atom Stream. The tracker accumulates events and flushes them when it meets one of the following conditions:

  1. Flush Interval is reached (default: 10 seconds).
  2. Bulk Length is reached (default: 4 events).
  3. Maximum Bulk size is reached (default: 64kB).

In case of failure the tracker will preform an exponential backoff with jitter. The tracker stores events in a memory storage based on Queue.

Using low level API methods

require 'json'
require 'iron_source_atom'

class TestExample

  def self.do_test_job
    url = "http://track.atom-data.io/"
    auth = ""
    atom = IronSourceAtom::Atom.new(auth)

    data_string = {
        id: 1,
        message: "hello_from_ruby"
    }.to_json

    response = atom.put_event("ibtest", data_string)
    puts "Response #{response.code} #{response.message}:
          #{response.body}"

    data1 = {
        id: 11,
        message: "first_array_data"
    }
    data2 = {
        id: 12,
        message: "second_array_data"
    }
    data3 = {
        id: 13,
        message: "third_array_data"
    }

    array_data_string = [data1, data2, data3].to_json

    response = atom.put_events("ibtest", array_data_string)
    puts "Response #{response.code} #{response.message}:
          #{response.body}"

  end

  do_test_job

end

Example

You can use our example for sending data to Atom:

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •