redis_logstash 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
 - data/.gitignore +1 -0
 - data/README.md +4 -3
 - data/lib/redis_logstash/socket.rb +46 -0
 - data/lib/redis_logstash/version.rb +1 -1
 - metadata +2 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,15 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            !binary "U0hBMQ==":
         
     | 
| 
       3 
3 
     | 
    
         
             
              metadata.gz: !binary |-
         
     | 
| 
       4 
     | 
    
         
            -
                 
     | 
| 
      
 4 
     | 
    
         
            +
                ZWU0MWI2ZmU2MzFhNmMyODkyY2MzYTdhZDZiMWU5NTYyOGNkZjI4Ng==
         
     | 
| 
       5 
5 
     | 
    
         
             
              data.tar.gz: !binary |-
         
     | 
| 
       6 
     | 
    
         
            -
                 
     | 
| 
      
 6 
     | 
    
         
            +
                YmE2YmExMTdkMzJlZWI5M2NlNzQ2ZjAzZTg2YWEzNWVhODk4Y2FlMQ==
         
     | 
| 
       7 
7 
     | 
    
         
             
            SHA512:
         
     | 
| 
       8 
8 
     | 
    
         
             
              metadata.gz: !binary |-
         
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
      
 9 
     | 
    
         
            +
                MjdkYzFkNzFkYjkzNDY1YTIyMTg5ZDc3NTA0YWNmNzhhYjI4NzEzMjUyNDZh
         
     | 
| 
      
 10 
     | 
    
         
            +
                NmQ4OGI4YmRkZDFiMThjYWIxNjMyOTM0ZDdjNTMxOTg0Y2MyNTY1ZTNlZDk5
         
     | 
| 
      
 11 
     | 
    
         
            +
                ZDdmMDA2ODU1NDQwMTM4YThhMDkwZDU3ZTEyZTUzNmFmNjI1MDg=
         
     | 
| 
       12 
12 
     | 
    
         
             
              data.tar.gz: !binary |-
         
     | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
       14 
     | 
    
         
            -
                 
     | 
| 
       15 
     | 
    
         
            -
                 
     | 
| 
      
 13 
     | 
    
         
            +
                YjM5YmRkYTNmYzFiMTAwNzEwMzNkOWQ5N2QzMTY4MTE3ZThhMWVjZGExZWMz
         
     | 
| 
      
 14 
     | 
    
         
            +
                MDI0MjQ2NzE1MGUyNTIyMDZhOGVhZmFmN2NjYjkzMzZiZTEyMzM5MzE1Yzc4
         
     | 
| 
      
 15 
     | 
    
         
            +
                NGI0ZTIwZDc3YmYwYTNkMzZhZGU5ZmUyMWQ2NzJiYTZlYjY3MWM=
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -16,10 +16,11 @@ Or install it yourself as: 
     | 
|
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                $ gem install redis_logstash
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 19 
     | 
    
         
            +
            Generate config file
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 21 
     | 
    
         
            +
                $ rails g redis_logstash
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            and set your redis credentials.
         
     | 
| 
       23 
24 
     | 
    
         | 
| 
       24 
25 
     | 
    
         
             
            ## Contributing
         
     | 
| 
       25 
26 
     | 
    
         | 
| 
         @@ -0,0 +1,46 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module RedisLogstash
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Socket
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
                @@socket = nil
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                attr_accessor :redis, :redis_key, :options
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 9 
     | 
    
         
            +
                  def get
         
     | 
| 
      
 10 
     | 
    
         
            +
                    @@socket ||= new
         
     | 
| 
      
 11 
     | 
    
         
            +
                  end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  def write(json)
         
     | 
| 
      
 14 
     | 
    
         
            +
                    get.push(json)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 20 
     | 
    
         
            +
                  self.options = ParseConfig.get[:redis]
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  host = options[:host] || '127.0.0.1'
         
     | 
| 
      
 23 
     | 
    
         
            +
                  port = options[:port] || 6379
         
     | 
| 
      
 24 
     | 
    
         
            +
                  password = options[:password] || nil
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  self.redis_key = options[:key] || 'logstash'
         
     | 
| 
      
 27 
     | 
    
         
            +
                  self.redis = password ? ::Redis.new(host: host, port: port, password: password) : ::Redis.new(host: host, port: port)
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                def push(json)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                    puts "#{{type: options[:type], message: json.to_json}.to_json}"
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    unless redis.rpush(redis_key, {type: options[:type], message: json.to_json}.to_json)
         
     | 
| 
      
 37 
     | 
    
         
            +
                      raise "could not send event to redis"
         
     | 
| 
      
 38 
     | 
    
         
            +
                    end
         
     | 
| 
      
 39 
     | 
    
         
            +
                  rescue ::Redis::InheritedError
         
     | 
| 
      
 40 
     | 
    
         
            +
                    redis.client.connect
         
     | 
| 
      
 41 
     | 
    
         
            +
                    retry
         
     | 
| 
      
 42 
     | 
    
         
            +
                  end
         
     | 
| 
      
 43 
     | 
    
         
            +
                end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: redis_logstash
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Marek Piechocki
         
     | 
| 
         @@ -70,6 +70,7 @@ files: 
     | 
|
| 
       70 
70 
     | 
    
         
             
            - lib/redis_logstash/action_controller_ext.rb
         
     | 
| 
       71 
71 
     | 
    
         
             
            - lib/redis_logstash/logger.rb
         
     | 
| 
       72 
72 
     | 
    
         
             
            - lib/redis_logstash/parse_config.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
            - lib/redis_logstash/socket.rb
         
     | 
| 
       73 
74 
     | 
    
         
             
            - lib/redis_logstash/version.rb
         
     | 
| 
       74 
75 
     | 
    
         
             
            - redis_logstash.gemspec
         
     | 
| 
       75 
76 
     | 
    
         
             
            homepage: ''
         
     |