fluent-plugin-azure-queue 0.0.5.pre → 0.0.6.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ce24e4937db26a3918accbc66d8b39692a1259c
4
- data.tar.gz: b9a068ff1a161c12e1f80cd8a6cb8ac716936dae
3
+ metadata.gz: b9216faa1348ea85dd618fcc498b31efea22eac1
4
+ data.tar.gz: 18989b0f648643a7f29d06f51c4b2d49b3850132
5
5
  SHA512:
6
- metadata.gz: 990edfb1e19407bf039dd05de4d388c4f54d65dd911712ccbac0a884bbe9a66657757448cf139b72f0357373f8c96e9a3882ac7a96a1a634099a1783b28f26de
7
- data.tar.gz: ecedf28bd3eced34c4405805c9f1845393b43ce7d15ee96a750231e3f6c00442f2b955ac0e0ecde51e17ffed7e38234415478cd22e217850c0620c4c20f126d8
6
+ metadata.gz: 9e721814bfb21da863ae2ec607743967a398c79719ba03330b7842f65cd8b27eb7e7968e685dabcd710528f5df3bcad3a2ef508507f481002aa51ebe860ed0a2
7
+ data.tar.gz: 3d2ce94dcd4f395a27e76c2bc7fa1605978914def55ee44d18b113cdbd204e31e70ad17396b38742e7ee65b2f1565a236ec7739e61abee605113ca108271702f
data/README.md CHANGED
@@ -20,7 +20,7 @@ fluentd v.12
20
20
  storage_account_name my_storage_account
21
21
  storage_access_key my_storage_access_key
22
22
  queue_name my_storage_queue
23
- fetch_interval 5
23
+ fetch_interval 5
24
24
  lease_duration 30
25
25
  </source>
26
26
 
@@ -69,7 +69,7 @@ public static void Run(string[] hubMessages, ICollector<string> outputQueue, Tra
69
69
  {
70
70
  outputQueue.Add(message);
71
71
  }
72
- else
72
+ else
73
73
  {
74
74
  log.Warning($"Message is larger than 64k with {bytes} bytes. Dropping message");
75
75
  }
@@ -77,7 +77,7 @@ public static void Run(string[] hubMessages, ICollector<string> outputQueue, Tra
77
77
  }
78
78
  ```
79
79
  ## azure_event_hub_capture Input Plugin
80
- This plugin is designed to work with blobs stored to a container via [Azure Event Hubs Capture](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-capture-overview)
80
+ This plugin is designed to work with blobs stored to a container via [Azure Event Hubs Capture](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-capture-overview)
81
81
 
82
82
  **Warning:** This plugin will delete the blobs after emitting the contents in fluentd.
83
83
 
@@ -89,8 +89,8 @@ This plugin is designed to work with blobs stored to a container via [Azure Even
89
89
  tag event_hub_input
90
90
  storage_account_name my_storage_account
91
91
  storage_access_key my_storage_access_key
92
- container_name my_capture_container
93
- fetch_interval 30
92
+ container_names my_capture_container
93
+ fetch_interval 30
94
94
  lease_duration 30
95
95
  </source>
96
96
 
@@ -106,9 +106,9 @@ The storage account name
106
106
 
107
107
  The storage account access key
108
108
 
109
- **container_name (required)**
109
+ **container_names (required)**
110
110
 
111
- The capture container name
111
+ The capture container names, comma separated.
112
112
 
113
113
  **message_key**
114
114
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5.pre
1
+ 0.0.6.pre
@@ -12,8 +12,8 @@ module Fluent
12
12
  config_param :storage_account_name, :string
13
13
  desc 'The azure storage account access key'
14
14
  config_param :storage_access_key, :string
15
- desc 'The container name'
16
- config_param :container_name, :string
15
+ desc 'The container name(s). Use commas to separate'
16
+ config_param :container_names, :string
17
17
  desc 'The the record key to put the message data into'
18
18
  config_param :message_key, :string, default: 'message'
19
19
  desc 'The time in seconds to sleep between fetching the blob list'
@@ -34,6 +34,7 @@ module Fluent
34
34
  :storage_account_name => @storage_account_name,
35
35
  :storage_access_key => @storage_access_key).blob_client
36
36
  @running = true
37
+ @containers = container_names.split(',').map { |c| c.strip }
37
38
 
38
39
  @thread = Thread.new(&method(:run))
39
40
  end
@@ -54,17 +55,19 @@ module Fluent
54
55
  while @running
55
56
  if Time.now > @next_fetch_time
56
57
  @next_fetch_time = Time.now + @fetch_interval
57
- begin
58
- blobs = @blob_client.list_blobs(@container_name)
59
- blobs = blobs.select { |b| b.properties[:lease_status] == "unlocked" }
60
- log.info("Found #{blobs.count} unlocked blobs", container_name: @container_name)
61
- # Blobs come back with oldest first
62
- blobs.each do |blob|
63
- ingest_blob(blob)
58
+ @containers.each do |container_name|
59
+ begin
60
+ blobs = @blob_client.list_blobs(container_name)
61
+ blobs = blobs.select { |b| b.properties[:lease_status] == "unlocked" }
62
+ log.info("Found #{blobs.count} unlocked blobs", container_name: container_name)
63
+ # Blobs come back with oldest first
64
+ blobs.each do |blob|
65
+ ingest_blob(container_name, blob)
66
+ end
67
+ rescue => e
68
+ log.warn(error: e)
69
+ log.warn_backtrace(e.backtrace)
64
70
  end
65
- rescue => e
66
- log.warn(error: e)
67
- log.warn_backtrace(e.backtrace)
68
71
  end
69
72
  else
70
73
  sleep(@next_fetch_time - Time.now)
@@ -72,18 +75,18 @@ module Fluent
72
75
  end
73
76
  end
74
77
 
75
- def ingest_blob(blob)
78
+ def ingest_blob(container_name, blob)
76
79
  begin
77
- lease_id = @blob_client.acquire_blob_lease(@container_name, blob.name, duration: @lease_duration)
80
+ lease_id = @blob_client.acquire_blob_lease(container_name, blob.name, duration: @lease_duration)
78
81
  log.info("Blob Leased", blob_name: blob.name)
79
- blob, blob_contents = @blob_client.get_blob(@container_name, blob.name)
82
+ blob, blob_contents = @blob_client.get_blob(container_name, blob.name)
80
83
  emit_blob_messages(blob_contents)
81
84
  log.trace("Done Ingest blob", blob_name: blob.name)
82
85
  begin
83
- delete_blob(blob, lease_id)
86
+ delete_blob(container_name, blob, lease_id)
84
87
  log.debug("Blob deleted", blob_name: blob.name)
85
88
  rescue Exception => e
86
- log.warn("Records emmitted but blob not deleted", container_name: @container_name, blob_name: blob.name, error: e)
89
+ log.warn("Records emmitted but blob not deleted", container_name: container_name, blob_name: blob.name, error: e)
87
90
  log.warn_backtrace(e.backtrace)
88
91
  end
89
92
  rescue Azure::Core::Http::HTTPError => e
@@ -121,10 +124,10 @@ module Fluent
121
124
  router.emit_stream(@tag, event_stream)
122
125
  end
123
126
 
124
- def delete_blob(blob, lease_id)
127
+ def delete_blob(container_name, blob, lease_id)
125
128
  # Hack because 'delete_blob' doesn't support lease_id yet
126
129
  Azure::Storage::Service::StorageService.register_request_callback { |headers| headers["x-ms-lease-id"] = lease_id }
127
- @blob_client.delete_blob(@container_name, blob.name)
130
+ @blob_client.delete_blob(container_name, blob.name)
128
131
  Azure::Storage::Service::StorageService.register_request_callback { |headers| headers }
129
132
  end
130
133
  end
@@ -15,7 +15,7 @@ class AzureEventHubCaptureInputTest < Test::Unit::TestCase
15
15
  tag test_tag
16
16
  storage_account_name test_storage_account_name
17
17
  storage_access_key test_storage_access_key
18
- container_name test_container_name
18
+ container_names test_container_name
19
19
  fetch_interval 1
20
20
  ]
21
21
 
@@ -26,13 +26,13 @@ class AzureEventHubCaptureInputTest < Test::Unit::TestCase
26
26
  end
27
27
 
28
28
  Struct.new("Blob", :name, :properties)
29
-
29
+
30
30
  def test_configure
31
31
  d = create_driver
32
32
  assert_equal 'test_tag', d.instance.tag
33
33
  assert_equal 'test_storage_account_name', d.instance.storage_account_name
34
34
  assert_equal 'test_storage_access_key', d.instance.storage_access_key
35
- assert_equal 'test_container_name', d.instance.container_name
35
+ assert_equal 'test_container_name', d.instance.container_names
36
36
  assert_equal 1, d.instance.fetch_interval
37
37
  end
38
38
 
@@ -42,11 +42,11 @@ class AzureEventHubCaptureInputTest < Test::Unit::TestCase
42
42
  flexmock(Azure::Storage::Client, :create => client)
43
43
  blob_client
44
44
  end
45
-
45
+
46
46
  def test_no_blobs
47
47
  d = create_driver
48
48
  blob_client = setup_mocks(d)
49
- blob_client.should_receive(:list_blobs).with(d.instance.container_name).and_return([]).once
49
+ blob_client.should_receive(:list_blobs).with(d.instance.container_names).and_return([]).once
50
50
  flexmock(d.instance).should_receive(:ingest_blob).never()
51
51
  d.run do
52
52
  sleep 1
@@ -57,10 +57,10 @@ class AzureEventHubCaptureInputTest < Test::Unit::TestCase
57
57
  d = create_driver
58
58
  blobs = [Struct::Blob.new("test1", lease_status: "unlocked"), Struct::Blob.new("test2", lease_status: "unlocked")]
59
59
  blob_client = setup_mocks(d)
60
- blob_client.should_receive(:list_blobs).with(d.instance.container_name).and_return(blobs).once
60
+ blob_client.should_receive(:list_blobs).with(d.instance.container_names).and_return(blobs).once
61
61
  plugin = flexmock(d.instance)
62
- plugin.should_receive(:ingest_blob).with(blobs[0]).once()
63
- plugin.should_receive(:ingest_blob).with(blobs[1]).once()
62
+ plugin.should_receive(:ingest_blob).with(d.instance.container_names, blobs[0]).once()
63
+ plugin.should_receive(:ingest_blob).with(d.instance.container_names, blobs[1]).once()
64
64
  d.run do
65
65
  sleep 1
66
66
  end
@@ -72,14 +72,14 @@ class AzureEventHubCaptureInputTest < Test::Unit::TestCase
72
72
  blob_client = setup_mocks(d)
73
73
  plugin = flexmock(d.instance)
74
74
  lease_id = "123"
75
- blob_client.should_receive(:acquire_blob_lease).with(d.instance.container_name, blob.name, duration: d.instance.lease_duration).and_return(lease_id).once
75
+ blob_client.should_receive(:acquire_blob_lease).with(d.instance.container_names, blob.name, duration: d.instance.lease_duration).and_return(lease_id).once
76
76
  updated_blob = Struct::Blob.new("test1", lease_status: "locked")
77
77
  blob_contents = flexmock("blob_contents")
78
- blob_client.should_receive(:get_blob).with(d.instance.container_name, blob.name).and_return([updated_blob, blob_contents]).once
78
+ blob_client.should_receive(:get_blob).with(d.instance.container_names, blob.name).and_return([updated_blob, blob_contents]).once
79
79
  plugin.should_receive(:emit_blob_messages).with(blob_contents).once
80
- plugin.should_receive(:delete_blob).with(updated_blob, lease_id).once
80
+ plugin.should_receive(:delete_blob).with(d.instance.container_names, updated_blob, lease_id).once
81
81
  d.run do
82
- plugin.send(:ingest_blob, blob)
82
+ plugin.send(:ingest_blob, d.instance.container_names, blob)
83
83
  end
84
84
  end
85
85
 
@@ -92,7 +92,7 @@ class AzureEventHubCaptureInputTest < Test::Unit::TestCase
92
92
  time = 1504030204
93
93
  time_string = Time.at(time).strftime("%m/%d/%Y %r")
94
94
  original_payload = {"key" => "value"}.to_json
95
- records = [ {"EnqueuedTimeUtc" => time_string, "Body" => original_payload } ]
95
+ records = [ {"EnqueuedTimeUtc" => time_string, "Body" => original_payload } ]
96
96
  flexmock(Avro::DataFile::Reader).should_receive(:new).with(buffer, Avro::IO::DatumReader).and_return(records)
97
97
  d.run do
98
98
  d.instance.send(:emit_blob_messages, test_payload)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-azure-queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5.pre
4
+ version: 0.0.6.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Bonebrake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-08 00:00:00.000000000 Z
11
+ date: 2017-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd