nfagent 0.9.11 → 0.9.13

Sign up to get free protection for your applications and to get access to all the features.
data/lib/nfagent.rb CHANGED
@@ -30,5 +30,5 @@ require 'nfagent/server'
30
30
  require 'nfagent/cli'
31
31
 
32
32
  module NFAgent
33
- VERSION = '0.9.11'
33
+ VERSION = '0.9.13'
34
34
  end
data/lib/nfagent/chunk.rb CHANGED
@@ -30,6 +30,8 @@ module NFAgent
30
30
  def dump
31
31
  Payload.new do |payload|
32
32
  Log.info("Dumping payload from chunk (#{@array.size} lines)")
33
+ payload.line_count = @array.size
34
+ payload.chunk_expired = expired?
33
35
  payload.data = Encoder.encode64url(Zlib::Deflate.deflate(@array.join("\n"), Zlib::BEST_COMPRESSION))
34
36
  payload.checksum = Digest::SHA1.hexdigest(payload.data)
35
37
  end
@@ -1,12 +1,12 @@
1
1
 
2
2
  module NFAgent
3
- class Payload < Struct.new(:data, :checksum, :filename)
3
+ class Payload < Struct.new(:data, :checksum, :filename, :line_count, :chunk_expired)
4
4
  def initialize
5
5
  yield self
6
6
  end
7
7
 
8
8
  def attempt
9
- @attempt || 1
9
+ @attempt || 0
10
10
  end
11
11
 
12
12
  def attempt=(value)
@@ -22,6 +22,15 @@ module NFAgent
22
22
  (self.data || "").size + 1
23
23
  end
24
24
 
25
+ def to_hash
26
+ {
27
+ "payload" => self.data,
28
+ "checksum" => self.checksum,
29
+ "line_count" => self.line_count,
30
+ "chunk_expired" => self.chunk_expired
31
+ }
32
+ end
33
+
25
34
  def write_to_disk(directory)
26
35
  File.open(File.join(directory, "#{self.checksum}-#{self.attempt}"), "w") do |file|
27
36
  file << self.data
@@ -10,9 +10,9 @@ module NFAgent
10
10
  def perform
11
11
  @payload.increment_attempt!
12
12
  fail(@payload) unless [ 1, 2, 4, 8, 16 ].include?(@payload.attempt)
13
- Log.info "Submitting Payload: #{@payload.checksum}, Attempt #{@payload.attempt}, (#{@payload.size} bytes)"
13
+ Log.info "Submitting Payload: #{@payload.checksum}, Attempt #{@payload.attempt}, (#{@payload.size} bytes, #{@payload.line_count} lines)"
14
14
  @payload.lock do
15
- response = Client.post(:collector, "payload" => @payload.data, "checksum" => @payload.checksum)
15
+ response = Client.post(:collector, @payload.to_hash)
16
16
  if response.ok?
17
17
  succeed(@payload)
18
18
  else
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 11
9
- version: 0.9.11
8
+ - 13
9
+ version: 0.9.13
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Draper