restash 0.2.1 → 0.3.1

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
- YjFiNDA4NjA4MzFiMTQ2ZWRlM2NkMDVkNmI0OWZlN2FiNDlkMjk1ZQ==
4
+ NDVhNzlhN2RhM2U0OWEwOGJmYzRjMGM5Njc4YmI2ODJiMGQyNmE3Zg==
5
5
  data.tar.gz: !binary |-
6
- ZGIyOGZlNWFiNzJmOTQ1ZmQ4NzQ5ZDI2YTY5NWE0ZWE2YmNmMTdkYg==
6
+ ZTAzODBkNDBmNDk5OGNhZTVlZjFiMDdkMDJmNjMyZmE2ZmIxOGM4ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGE1NTUwYzkxNWMwNGZkNDUwYTVlNzI2NmRlYjJkMTU1NWM0NTM3ODdhNDRk
10
- N2FmNDJiODgyNDAzYWIyZjJkZGM5YmYwMjljNGJmMjJkZWE2MmUwOWQ4NjU2
11
- ZTYwMTRkNGZmZDMyYzg0YzkyYTdjZDkzYzM5NGNlNWNkNTk5Nzk=
9
+ YWRjNzQxNGRkOGQ1YTE0MTkwNjZmMTJiYzJlM2FiOTAzODFiOGUyNDg3ZTQw
10
+ OTkwMTUzN2I3MTNkNWM5YzQ5NjU0NWY3MjQyMDE3OTgwNDk1YmExOTEyMDZh
11
+ OTY5Y2Y0YzlhOGEzOGZiNGNkNDVlNzg3M2EwYzZhZjM2ZDhiMGY=
12
12
  data.tar.gz: !binary |-
13
- MDNiYjI1NDE4ZDhlMWUxYTI2M2RiMTY4MWQ5MTEwMzIyYjdhOGM5N2U1MjY0
14
- NDhlNzI5NDI5YjA4Yjk2MDBhYThiYWE1YjMzY2QxNjE5OGMwNWFmNTcwN2Q3
15
- NTEzMGZiMjg4ODFhZGQ4MGUxMjM3OTAzYzgzMmVkYjJlZWJlZGM=
13
+ Y2M2YjNkZTQxMTNlNzQ0YWZmNWVhODZmOGRmMzI3MDBkMDdkM2RlNTY4ZWM2
14
+ YTkwZmVlNDMwZGY3Y2U3N2Q3NTFjZWYwODQ4YjllNDIwOGM0MTcyNTVjZDFi
15
+ MDg4ZGNjMjY1ZDU4ZDZkY2RjNjMzYTlhY2VlMDY4YmQ2OTg3NjU=
@@ -3,7 +3,11 @@ language: ruby
3
3
  rvm:
4
4
  - 2.2
5
5
  - 2.3
6
- - 2.4
6
+ - head
7
+ matrix:
8
+ allow_failures:
9
+ - rvm: head
10
+ - rvm: 2.3
7
11
  before_install: gem install bundler -v 1.12.5
8
12
  deploy:
9
13
  api_key:
@@ -11,4 +15,4 @@ deploy:
11
15
  provider: rubygems
12
16
  on:
13
17
  rvm: 2.2
14
- all_branches: true
18
+ branch: master
data/README.md CHANGED
@@ -10,14 +10,17 @@ Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Lo
10
10
  Resque::Failure.backend = Resque::Failure::Multiple
11
11
  ```
12
12
 
13
- Configure logstash host and port (currently support only udp)
13
+ Configure logstash host and port. Supports only tcp, due to the large payload. A timeout can be passed in the options.
14
14
  ```
15
15
  Restash::Conf.configure do |conf|
16
16
  conf.logstash_host = ENV['LOGSTASH_HOST']
17
17
  conf.logstash_port = ENV['LOGSTASH_PORT']
18
+ conf.options = {connect_timeout: timeout1, write_timeout: timeout2, read_timeout: timeout3}
18
19
  end
19
20
  ```
20
21
 
22
+ Additional options can be explored in the [TCPTimeout](https://github.com/lann/tcp-timeout-ruby) project. The options are passed as is to a new TCPTimeout::TCPSocket object on every message.
23
+
21
24
 
22
25
  ## License
23
26
 
@@ -7,11 +7,12 @@ module Resque
7
7
 
8
8
  def save
9
9
  begin
10
- Restash::Conf.logger.fatal exception: exception.to_s,
11
- failure_line: exception.backtrace[0],
12
- worker: worker.to_s,
13
- queue: queue,
14
- payload: payload
10
+ Restash::Conf.logger.write({ exception: exception.to_s,
11
+ backtrace: exception.backtrace,
12
+ worker: worker.to_s,
13
+ queue: queue,
14
+ payload: payload,
15
+ tags: [:resque_failure] }.to_json)
15
16
  rescue => e
16
17
  puts "Failed to send to logstash: #{e.message}\n#{e.backtrace}"
17
18
  end
@@ -1,11 +1,11 @@
1
- require 'logstash-logger'
1
+ require 'restash/logger'
2
2
 
3
3
  module Restash
4
4
  class Conf
5
5
 
6
6
  class << self
7
7
 
8
- attr_accessor :logstash_host, :logstash_port
8
+ attr_accessor :logstash_host, :logstash_port, :options
9
9
 
10
10
  def configure
11
11
  yield self
@@ -13,7 +13,7 @@ module Restash
13
13
  end
14
14
 
15
15
  def logger
16
- @logger ||= LogStashLogger.new(logstash_host, logstash_port)
16
+ @logger ||= Restash::Logger.new(logstash_host, logstash_port, options)
17
17
  end
18
18
 
19
19
  end
@@ -0,0 +1,20 @@
1
+ require 'tcp_timeout'
2
+
3
+ module Restash
4
+ class Logger
5
+
6
+ def initialize(host, port, options)
7
+ @host = host
8
+ @port = port
9
+ @options = options
10
+ end
11
+
12
+ def write(data)
13
+ sock = TCPTimeout::TCPSocket.new(@host, @port, @options)
14
+ sock.write(data)
15
+ sock.close
16
+ end
17
+
18
+ end
19
+ end
20
+
@@ -1,3 +1,3 @@
1
1
  module Restash
2
- VERSION = '0.2.1'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency 'bundler', '~> 1.12'
23
23
  spec.add_development_dependency 'rake', '~> 10.0'
24
24
  spec.add_development_dependency 'rspec', '~> 3.0'
25
- spec.add_runtime_dependency 'logstash-logger'
26
25
  spec.add_runtime_dependency 'resque'
27
26
  spec.add_runtime_dependency 'json'
27
+ spec.add_runtime_dependency 'tcp_timeout'
28
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariel Cabib
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-06 00:00:00.000000000 Z
11
+ date: 2016-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: logstash-logger
56
+ name: resque
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ! '>='
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: resque
70
+ name: json
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ! '>='
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: json
84
+ name: tcp_timeout
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ! '>='
@@ -112,6 +112,7 @@ files:
112
112
  - bin/setup
113
113
  - lib/resque/failure/logstash.rb
114
114
  - lib/restash/conf.rb
115
+ - lib/restash/logger.rb
115
116
  - lib/restash/resque_server.rb
116
117
  - lib/restash/version.rb
117
118
  - restash.gemspec