Skip to content

Commit

Permalink
Merge pull request #2670 from ganmacs/add-ext_monintor
Browse files Browse the repository at this point in the history
Add ext_monitor gem to improve Monitor class's operations
  • Loading branch information
ganmacs authored Jan 9, 2020
2 parents 19f9d42 + 0a772f2 commit 8610cd7
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 8 deletions.
1 change: 1 addition & 0 deletions fluentd.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ Gem::Specification.new do |gem|
gem.add_development_dependency("test-unit", ["~> 3.2"])
gem.add_development_dependency("test-unit-rr", ["~> 1.0"])
gem.add_development_dependency("oj", [">= 2.14", "< 4"])
gem.add_development_dependency("ext_monitor", [">= 0.1.1", "< 0.2"])
end
4 changes: 1 addition & 3 deletions lib/fluent/command/cat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,11 @@
usage $!.to_s
end


require 'thread'
require 'monitor'
require 'socket'
require 'yajl'
require 'msgpack'

require 'fluent/ext_monitor_require'

class Writer
include MonitorMixin
Expand Down
28 changes: 28 additions & 0 deletions lib/fluent/ext_monitor_require.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Fluentd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# To avoid duplicated requirements, extract this logic as file.

if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.7.0')
require 'monitor'
else
begin
# monitor_ext is bundled since ruby 2.7.0
require 'ext_monitor'
rescue LoadError => _
require 'monitor'
end
end
2 changes: 1 addition & 1 deletion lib/fluent/load.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require 'socket'
require 'fcntl'
require 'time'
require 'monitor'
require 'stringio'
require 'fileutils'
require 'json'
Expand Down Expand Up @@ -33,3 +32,4 @@
require 'fluent/output'
require 'fluent/filter'
require 'fluent/match'
require 'fluent/ext_monitor_require'
3 changes: 1 addition & 2 deletions lib/fluent/plugin/buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
require 'fluent/plugin/base'
require 'fluent/plugin/owned_by_mixin'
require 'fluent/unique_id'

require 'monitor'
require 'fluent/ext_monitor_require'

module Fluent
module Plugin
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/buffer/chunk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
require 'fluent/plugin/compressable'
require 'fluent/unique_id'
require 'fluent/event'
require 'fluent/ext_monitor_require'

require 'monitor'
require 'tempfile'
require 'zlib'

Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
require 'fluent/timezone'
require 'fluent/unique_id'
require 'fluent/clock'
require 'fluent/ext_monitor_require'

require 'time'
require 'monitor'

module Fluent
module Plugin
Expand Down

0 comments on commit 8610cd7

Please sign in to comment.