logstash-output-kusto 1.0.5-java → 1.0.6-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,81 +1,81 @@
1
- # encoding: utf-8
2
-
3
- require 'logstash/outputs/base'
4
- require 'logstash/namespace'
5
- require 'logstash/errors'
6
-
7
- class LogStash::Outputs::Kusto < LogStash::Outputs::Base
8
- ##
9
- # Bare-bones utility for running a block of code at an interval.
10
- #
11
- class Interval
12
- ##
13
- # Initializes a new Interval with the given arguments and starts it
14
- # before returning it.
15
- #
16
- # @param interval [Integer] (see: Interval#initialize)
17
- # @param procsy [#call] (see: Interval#initialize)
18
- #
19
- # @return [Interval]
20
- #
21
- def self.start(interval, procsy)
22
- new(interval, procsy).tap(&:start)
23
- end
24
-
25
- ##
26
- # @param interval [Integer]: time in seconds to wait between calling the given proc
27
- # @param procsy [#call]: proc or lambda to call periodically; must not raise exceptions.
28
- def initialize(interval, procsy)
29
- @interval = interval
30
- @procsy = procsy
31
-
32
- # Mutex, ConditionVariable, etc.
33
- @mutex = Mutex.new
34
- @sleeper = ConditionVariable.new
35
- end
36
-
37
- ##
38
- # Starts the interval, or returns if it has already been started.
39
- #
40
- # @return [void]
41
- def start
42
- @mutex.synchronize do
43
- return if @thread && @thread.alive?
44
-
45
- @thread = Thread.new { run }
46
- end
47
- end
48
-
49
- ##
50
- # Stop the interval.
51
- # Does not interrupt if execution is in-progress.
52
- def stop
53
- @mutex.synchronize do
54
- @stopped = true
55
- end
56
-
57
- @thread && @thread.join
58
- end
59
-
60
- ##
61
- # @return [Boolean]
62
- def alive?
63
- @thread && @thread.alive?
64
- end
65
-
66
- private
67
-
68
- def run
69
- @mutex.synchronize do
70
- loop do
71
- @sleeper.wait(@mutex, @interval)
72
- break if @stopped
73
-
74
- @procsy.call
75
- end
76
- end
77
- ensure
78
- @sleeper.broadcast
79
- end
80
- end
81
- end
1
+ # encoding: utf-8
2
+
3
+ require 'logstash/outputs/base'
4
+ require 'logstash/namespace'
5
+ require 'logstash/errors'
6
+
7
+ class LogStash::Outputs::Kusto < LogStash::Outputs::Base
8
+ ##
9
+ # Bare-bones utility for running a block of code at an interval.
10
+ #
11
+ class Interval
12
+ ##
13
+ # Initializes a new Interval with the given arguments and starts it
14
+ # before returning it.
15
+ #
16
+ # @param interval [Integer] (see: Interval#initialize)
17
+ # @param procsy [#call] (see: Interval#initialize)
18
+ #
19
+ # @return [Interval]
20
+ #
21
+ def self.start(interval, procsy)
22
+ new(interval, procsy).tap(&:start)
23
+ end
24
+
25
+ ##
26
+ # @param interval [Integer]: time in seconds to wait between calling the given proc
27
+ # @param procsy [#call]: proc or lambda to call periodically; must not raise exceptions.
28
+ def initialize(interval, procsy)
29
+ @interval = interval
30
+ @procsy = procsy
31
+
32
+ # Mutex, ConditionVariable, etc.
33
+ @mutex = Mutex.new
34
+ @sleeper = ConditionVariable.new
35
+ end
36
+
37
+ ##
38
+ # Starts the interval, or returns if it has already been started.
39
+ #
40
+ # @return [void]
41
+ def start
42
+ @mutex.synchronize do
43
+ return if @thread && @thread.alive?
44
+
45
+ @thread = Thread.new { run }
46
+ end
47
+ end
48
+
49
+ ##
50
+ # Stop the interval.
51
+ # Does not interrupt if execution is in-progress.
52
+ def stop
53
+ @mutex.synchronize do
54
+ @stopped = true
55
+ end
56
+
57
+ @thread && @thread.join
58
+ end
59
+
60
+ ##
61
+ # @return [Boolean]
62
+ def alive?
63
+ @thread && @thread.alive?
64
+ end
65
+
66
+ private
67
+
68
+ def run
69
+ @mutex.synchronize do
70
+ loop do
71
+ @sleeper.wait(@mutex, @interval)
72
+ break if @stopped
73
+
74
+ @procsy.call
75
+ end
76
+ end
77
+ ensure
78
+ @sleeper.broadcast
79
+ end
80
+ end
81
+ end