fluent-plugin-azure-queue 0.0.8.pre → 0.0.11.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37078952b1ed7c05bf93e680880cefb7972f7bcd
|
4
|
+
data.tar.gz: 92a27fe6426bdcb45af5376ee63c071fc786021c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b35295865bc0d3703a843cfb49d0c751ad2186dda249861b108c1af36d65381d8d97e671923ea9bdbe47b215a0886411f8d71ea484b898f661029623bc5d63b
|
7
|
+
data.tar.gz: 08cc210e8ae481c643b9614ffa71087a8f0867b2d00b40d40d877b1d8a8f727cfb058c2385badb75734ec25e93d0dc6d2f14b9f0779e9af76474f68e80c128d6
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.11.pre
|
@@ -16,7 +16,8 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.require_paths = ['lib']
|
17
17
|
|
18
18
|
gem.add_dependency "fluentd", [">= 0.12.2", "< 0.14"]
|
19
|
-
gem.add_dependency "azure-storage", [">= 0.
|
19
|
+
gem.add_dependency "azure-storage-blob", [">= 1.0.1", "< 1.1.0"]
|
20
|
+
gem.add_dependency "azure-storage-queue", [">= 1.0.1", "< 1.1.0"]
|
20
21
|
gem.add_dependency "nokogiri"
|
21
22
|
gem.add_dependency "concurrent-ruby"
|
22
23
|
gem.add_dependency "avro", ">= 1.8"
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'fluent/input'
|
2
|
-
require 'azure/storage'
|
2
|
+
require 'azure/storage/common'
|
3
|
+
require "azure/storage/blob"
|
4
|
+
require "azure/storage/queue"
|
3
5
|
require "avro"
|
4
6
|
|
5
7
|
module Fluent
|
@@ -34,9 +36,11 @@ module Fluent
|
|
34
36
|
if @lease_duration > 60 || @lease_duration < 15
|
35
37
|
raise Fluent::ConfigError, "fluent-plugin-azure-queue: 'lease_duration' parameter must be between 15 and 60: #{@lease_duration}"
|
36
38
|
end
|
37
|
-
|
39
|
+
azure_client = Azure::Storage::Common::Client.create(
|
38
40
|
:storage_account_name => @storage_account_name,
|
39
41
|
:storage_access_key => @storage_access_key)
|
42
|
+
@blob_client = Azure::Storage::Blob::BlobService.new(client: azure_client)
|
43
|
+
@queue_client = Azure::Storage::Queue::QueueService.new(client: azure_client)
|
40
44
|
@running = true
|
41
45
|
@containers = container_names.split(',').map { |c| c.strip }
|
42
46
|
|
@@ -73,7 +77,7 @@ module Fluent
|
|
73
77
|
def ingest_from_blob_list
|
74
78
|
@containers.each do |container_name|
|
75
79
|
begin
|
76
|
-
blobs = @
|
80
|
+
blobs = @blob_client.list_blobs(container_name)
|
77
81
|
blobs = blobs.select { |b| b.properties[:lease_status] == "unlocked" }
|
78
82
|
log.info("Found #{blobs.count} unlocked blobs", container_name: container_name)
|
79
83
|
# Blobs come back with oldest first
|
@@ -89,11 +93,11 @@ module Fluent
|
|
89
93
|
|
90
94
|
def ingest_from_queue
|
91
95
|
begin
|
92
|
-
blob_id_messages = @
|
96
|
+
blob_id_messages = @queue_client.list_messages(@queue_name, @queue_lease_time, { number_of_messages: 32 })
|
93
97
|
blob_id_messages.each do |blob_id_message|
|
94
98
|
blob_id = JSON.parse(Base64.decode64(blob_id_message.message_text))
|
95
99
|
ingest_blob(blob_id["Container"], blob_id["Name"])
|
96
|
-
@
|
100
|
+
@queue_client.delete_message(@queue_name, blob_id_message.id, blob_id_message.pop_receipt)
|
97
101
|
end
|
98
102
|
rescue => e
|
99
103
|
log.warn(error: e)
|
@@ -103,13 +107,13 @@ module Fluent
|
|
103
107
|
|
104
108
|
def ingest_blob(container_name, blob_name)
|
105
109
|
begin
|
106
|
-
lease_id = @
|
110
|
+
lease_id = @blob_client.acquire_blob_lease(container_name, blob_name, duration: @lease_duration)
|
107
111
|
log.info("Blob Leased", blob_name: blob_name)
|
108
|
-
blob, blob_contents = @
|
112
|
+
blob, blob_contents = @blob_client.get_blob(container_name, blob_name)
|
109
113
|
emit_blob_messages(blob_contents)
|
110
114
|
log.trace("Done Ingest blob", blob_name: blob_name)
|
111
115
|
begin
|
112
|
-
delete_blob(container_name,
|
116
|
+
@blob_client.delete_blob(container_name, blob_name, lease_id: lease_id)
|
113
117
|
log.debug("Blob deleted", blob_name: blob_name)
|
114
118
|
rescue Exception => e
|
115
119
|
log.warn("Records emmitted but blob not deleted", container_name: container_name, blob_name: blob_name, error: e)
|
@@ -149,12 +153,5 @@ module Fluent
|
|
149
153
|
end
|
150
154
|
router.emit_stream(@tag, event_stream)
|
151
155
|
end
|
152
|
-
|
153
|
-
def delete_blob(container_name, blob, lease_id)
|
154
|
-
# Hack because 'delete_blob' doesn't support lease_id yet
|
155
|
-
Azure::Storage::Service::StorageService.register_request_callback { |headers| headers["x-ms-lease-id"] = lease_id }
|
156
|
-
@azure_client.blob_client.delete_blob(container_name, blob.name)
|
157
|
-
Azure::Storage::Service::StorageService.register_request_callback { |headers| headers }
|
158
|
-
end
|
159
156
|
end
|
160
157
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'fluent/input'
|
2
|
-
require 'azure/storage'
|
2
|
+
require 'azure/storage/queue'
|
3
3
|
require 'concurrent'
|
4
4
|
|
5
5
|
module Fluent
|
@@ -27,9 +27,9 @@ module Fluent
|
|
27
27
|
|
28
28
|
def start
|
29
29
|
super
|
30
|
-
@queue_client = Azure::Storage::
|
30
|
+
@queue_client = Azure::Storage::Queue::QueueService.create(
|
31
31
|
:storage_account_name => @storage_account_name,
|
32
|
-
:storage_access_key => @storage_access_key)
|
32
|
+
:storage_access_key => @storage_access_key)
|
33
33
|
log.debug("Succeeded to creating azure queue client")
|
34
34
|
@running = true
|
35
35
|
|
@@ -50,8 +50,9 @@ class AzureEventHubCaptureInputTest < Test::Unit::TestCase
|
|
50
50
|
def setup_mocks(driver)
|
51
51
|
blob_client = flexmock("blob_client")
|
52
52
|
queue_client = flexmock("queue_client")
|
53
|
-
|
54
|
-
flexmock(Azure::Storage::
|
53
|
+
flexmock(Azure::Storage::Common::Client, :create => nil)
|
54
|
+
flexmock(Azure::Storage::Queue::QueueService, :new => queue_client)
|
55
|
+
flexmock(Azure::Storage::Blob::BlobService, :new => blob_client)
|
55
56
|
[blob_client, queue_client]
|
56
57
|
end
|
57
58
|
|
@@ -71,8 +72,8 @@ class AzureEventHubCaptureInputTest < Test::Unit::TestCase
|
|
71
72
|
blob_client, queue_client = setup_mocks(d)
|
72
73
|
blob_client.should_receive(:list_blobs).with(d.instance.container_names).and_return(blobs).once
|
73
74
|
plugin = flexmock(d.instance)
|
74
|
-
plugin.should_receive(:ingest_blob).with(d.instance.container_names, blobs[0]).once()
|
75
|
-
plugin.should_receive(:ingest_blob).with(d.instance.container_names, blobs[1]).once()
|
75
|
+
plugin.should_receive(:ingest_blob).with(d.instance.container_names, blobs[0].name).once()
|
76
|
+
plugin.should_receive(:ingest_blob).with(d.instance.container_names, blobs[1].name).once()
|
76
77
|
d.run do
|
77
78
|
sleep 1
|
78
79
|
end
|
@@ -121,11 +122,11 @@ class AzureEventHubCaptureInputTest < Test::Unit::TestCase
|
|
121
122
|
blob_client.should_receive(:acquire_blob_lease).with(d.instance.container_names, blob.name, duration: d.instance.lease_duration).and_return(lease_id).once
|
122
123
|
updated_blob = Struct::Blob.new("test1", lease_status: "locked")
|
123
124
|
blob_contents = flexmock("blob_contents")
|
124
|
-
blob_client.should_receive(:get_blob).with(d.instance.container_names,
|
125
|
+
blob_client.should_receive(:get_blob).with(d.instance.container_names, blob.name).and_return([updated_blob, blob_contents]).once
|
125
126
|
plugin.should_receive(:emit_blob_messages).with(blob_contents).once
|
126
|
-
|
127
|
+
blob_client.should_receive(:delete_blob).with(d.instance.container_names, updated_blob.name, lease_id: lease_id).once
|
127
128
|
d.run do
|
128
|
-
plugin.send(:ingest_blob, d.instance.container_names, blob)
|
129
|
+
plugin.send(:ingest_blob, d.instance.container_names, blob.name)
|
129
130
|
end
|
130
131
|
end
|
131
132
|
|
data/test/test_in_azure_queue.rb
CHANGED
@@ -41,8 +41,7 @@ class AzureQueueInputTest < Test::Unit::TestCase
|
|
41
41
|
driver.instance.queue_name,
|
42
42
|
driver.instance.lease_time,
|
43
43
|
{ number_of_messages: 1}).and_return(messages).once
|
44
|
-
|
45
|
-
flexmock(Azure::Storage::Client, :create => client)
|
44
|
+
flexmock(Azure::Storage::Queue::QueueService, :create => queue_client)
|
46
45
|
queue_client
|
47
46
|
end
|
48
47
|
|
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.
|
4
|
+
version: 0.0.11.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:
|
11
|
+
date: 2018-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -31,25 +31,45 @@ dependencies:
|
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '0.14'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name: azure-storage
|
34
|
+
name: azure-storage-blob
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.
|
39
|
+
version: 1.0.1
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 1.1.0
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
49
|
+
version: 1.0.1
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
52
|
+
version: 1.1.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: azure-storage-queue
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.0.1
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.1.0
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.0.1
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.1.0
|
53
73
|
- !ruby/object:Gem::Dependency
|
54
74
|
name: nokogiri
|
55
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
192
|
version: 1.3.1
|
173
193
|
requirements: []
|
174
194
|
rubyforge_project:
|
175
|
-
rubygems_version: 2.
|
195
|
+
rubygems_version: 2.6.14
|
176
196
|
signing_key:
|
177
197
|
specification_version: 4
|
178
198
|
summary: Fluent input plugin for azure queue input
|