Sha256: 7bceffe6093815cd4d2db7fd3b84ef6a3347017f8613f545fc51b6bcbb0a82b1

Contents?: true

Size: 1.12 KB

Versions: 20

Compression:

Stored size: 1.12 KB

Contents

#!/usr/bin/env ruby
$: << "lib"

require "rubygems"
require "logstash/agent"
require "yaml"

collector_config = YAML.load <<"YAML"
---
inputs:
  foo:
  - internal:///
outputs:
- amqp://localhost/topic/logstash/testing
YAML

receiver_config = YAML.load <<"YAML"
---
inputs:
  foo:
  - amqp://localhost/topic/logstash/testing
outputs:
- internal:///
YAML

collector_agent = LogStash::Agent.new(collector_config)
receiver_agent = LogStash::Agent.new(receiver_config)

data = ["hello world", "foo", "bar"]

EventMachine::run do
  receiver_agent.register
  collector_agent.register

  EM::next_tick do
    # Register output callback on the receiver
    receiver_agent.outputs\
        .find { |o| o.is_a?(LogStash::Outputs::Internal) }\
        .callback do |event|
      puts event
      #puts expect.first == event.message
      #expect.shift
      #agent.stop
    end

    EM::next_tick do
      # Send input to the collector
      expect = data.clone
      input = collector_agent.inputs\
        .find { |i| i.is_a?(LogStash::Inputs::Internal) }
      channel = input.channel
      data.each { |message| channel.push(message) }
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
logstash-lite-0.2.20110505142231 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20110422152244 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20110405105201 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20110331121236 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20110329105411 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20110206003603 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20110203130400 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20110122143801 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20110112115019 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20101222161646 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20101208111718 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20101207114354 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20101201111523 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20101129210156 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20101129205551 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20101129155412 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20101124030048 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20101124004656 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20101123134625 examples/sample-agent-in-ruby.rb
logstash-lite-0.2.20101123133737 examples/sample-agent-in-ruby.rb