redis_logstash 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTJjYTFlMGE5N2MzOTVjMjVlMzA3Mzk4ZTRkMWU4MmRhMTQyZmNjNg==
4
+ ZWU0MWI2ZmU2MzFhNmMyODkyY2MzYTdhZDZiMWU5NTYyOGNkZjI4Ng==
5
5
  data.tar.gz: !binary |-
6
- MmFiYTBlNzgzYmIyMTQyNGM5OTZhZGE2MTc4YzQ4N2RiN2ZiMjc5OQ==
6
+ YmE2YmExMTdkMzJlZWI5M2NlNzQ2ZjAzZTg2YWEzNWVhODk4Y2FlMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGU5N2FhNTUwNjQ4YmM0NmNkNDBhYTAxZWYxN2I2OTA4NjA3MjUzMWYyOWQ1
10
- MThjNTZmOGExMzAyNzgyNDk2ZmU5NWUzMWFhNjBjZTMyMzE1YzRlZDg2Y2Yy
11
- ZjVjYTExZGFhMDk5NzBjZjVhY2I2MzEyMzI1NmM3MjM0OWQ5YmM=
9
+ MjdkYzFkNzFkYjkzNDY1YTIyMTg5ZDc3NTA0YWNmNzhhYjI4NzEzMjUyNDZh
10
+ NmQ4OGI4YmRkZDFiMThjYWIxNjMyOTM0ZDdjNTMxOTg0Y2MyNTY1ZTNlZDk5
11
+ ZDdmMDA2ODU1NDQwMTM4YThhMDkwZDU3ZTEyZTUzNmFmNjI1MDg=
12
12
  data.tar.gz: !binary |-
13
- YTcyNDVlMmI3NGQxYTQxNmYwYzhjMDM3YzcxZDEzZDBhNTc0ZjI1NmVjZDZi
14
- NGRkOTY3YzMwMmNkYzVjNGM4MTUwOTZhOTAzNGViYjQyYzMyZmQwNzNiMWNk
15
- NTQ3NTQwNzJmNDM2Mzk2MDdkOWY2ZjNjMmM0NDBmNDI3NDFiZjE=
13
+ YjM5YmRkYTNmYzFiMTAwNzEwMzNkOWQ5N2QzMTY4MTE3ZThhMWVjZGExZWMz
14
+ MDI0MjQ2NzE1MGUyNTIyMDZhOGVhZmFmN2NjYjkzMzZiZTEyMzM5MzE1Yzc4
15
+ NGI0ZTIwZDc3YmYwYTNkMzZhZGU5ZmUyMWQ2NzJiYTZlYjY3MWM=
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .idea
data/README.md CHANGED
@@ -16,10 +16,11 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install redis_logstash
18
18
 
19
- ## Usage
19
+ Generate config file
20
20
 
21
- Run rails g redis_logstash to generate redis_logstash.yml config file.
22
- Then set your redis credentials
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
@@ -1,3 +1,3 @@
1
1
  module RedisLogstash
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  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.1
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: ''