Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dependencies between files #799

Merged
merged 2 commits into from
Feb 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/fluent/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
module Fluent
require 'fluent/configurable'
require 'fluent/engine'

require 'fluent/configurable'
require 'fluent/engine'
require 'fluent/plugin'
require 'fluent/output'

module Fluent
#
# Agent is a resource unit who manages emittable plugins
#
Expand Down
6 changes: 6 additions & 0 deletions lib/fluent/buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'monitor'
require 'fileutils'

require 'fluent/configurable'

module Fluent
class BufferError < StandardError
end
Expand Down
3 changes: 3 additions & 0 deletions lib/fluent/command/bundler_injection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
# limitations under the License.
#

require 'rbconfig'
require 'rubygems'

if ENV['BUNDLE_BIN_PATH']
puts 'error: You seem to use `bundle exec` already.'
exit 1
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/command/cat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
message_key = s
}

(class<<self;self;end).module_eval do
(class << self; self; end).module_eval do
define_method(:usage) do |msg|
puts op.to_s
puts "error: #{msg}" if msg
Expand Down
5 changes: 3 additions & 2 deletions lib/fluent/command/debug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
unix = b
}

(class<<self;self;end).module_eval do
(class << self; self; end).module_eval do
define_method(:usage) do |msg|
puts op.to_s
puts "error: #{msg}" if msg
Expand All @@ -60,7 +60,8 @@
uri = "druby://#{host}:#{port}"
end

require 'fluent/load'
require 'fluent/log'
require 'fluent/engine'

$log = Fluent::Log.new(STDERR, Fluent::Log::LEVEL_TRACE)
Fluent::Engine.init
Expand Down
3 changes: 2 additions & 1 deletion lib/fluent/command/fluentd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#

require 'optparse'

require 'fluent/supervisor'
require 'fluent/log'
require 'fluent/env'
Expand Down Expand Up @@ -142,7 +143,7 @@
end


(class<<self;self;end).module_eval do
(class << self; self; end).module_eval do
define_method(:usage) do |msg|
puts op.to_s
puts "error: #{msg}" if msg
Expand Down
9 changes: 4 additions & 5 deletions lib/fluent/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
# limitations under the License.
#

module Fluent
require 'fluent/config/error'
require 'fluent/config/element'
require 'fluent/config/error'
require 'fluent/config/element'
require 'fluent/configurable'

module Fluent
module Config
def self.parse(str, fname, basepath = Dir.pwd, v1_config = false)
if fname =~ /\.rb$/
Expand All @@ -39,8 +40,6 @@ def self.new(name = '')
end
end

require 'fluent/configurable'

module PluginId
def configure(conf)
@id = conf['@id'] || conf['id']
Expand Down
7 changes: 3 additions & 4 deletions lib/fluent/config/basic_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
# limitations under the License.
#

require 'stringio'
require 'fluent/config/error'

module Fluent
module Config

require 'stringio'
require 'fluent/config/error'

class BasicParser
def initialize(strscan)
@ss = strscan
Expand Down
2 changes: 2 additions & 0 deletions lib/fluent/config/configure_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# limitations under the License.
#

require 'fluent/configurable'

module Fluent
module Config
class ConfigureProxy
Expand Down
3 changes: 3 additions & 0 deletions lib/fluent/config/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
# limitations under the License.
#

require 'json'

require 'fluent/config'
require 'fluent/config/element'

module Fluent
module Config
Expand Down
5 changes: 3 additions & 2 deletions lib/fluent/config/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
# limitations under the License.
#

module Fluent
require 'fluent/config/error'
require 'fluent/config/error'
require 'fluent/config/literal_parser'

module Fluent
module Config
class Element < Hash
def initialize(name, arg, attrs, elements, unused = nil)
Expand Down
13 changes: 8 additions & 5 deletions lib/fluent/config/literal_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
# limitations under the License.
#

module Fluent
module Config
require 'stringio'

require 'json'
require 'yajl'
require 'irb/ruby-lex' # RubyLex

require 'yajl'
require 'fluent/config/basic_parser'
require 'irb/ruby-lex' # RubyLex
require 'fluent/config/basic_parser'

module Fluent
module Config
class LiteralParser < BasicParser
def self.unescape_char(c)
case c
Expand Down
8 changes: 5 additions & 3 deletions lib/fluent/config/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
# limitations under the License.
#

require 'uri'

require 'fluent/config/error'
require 'fluent/config/element'

module Fluent
module Config
require 'fluent/config/error'
require 'fluent/config/element'

class Parser
def self.parse(io, fname, basepath = Dir.pwd)
attrs, elems = Parser.new(basepath, io.each_line, fname).parse!(true)
Expand Down
6 changes: 3 additions & 3 deletions lib/fluent/config/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

require 'json'

module Fluent
require 'fluent/config/error'
require 'fluent/config/v1_parser'
require 'fluent/config/error'
require 'fluent/config/v1_parser'

module Fluent
module Config
class Section < BasicObject
def self.name
Expand Down
7 changes: 5 additions & 2 deletions lib/fluent/config/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
# limitations under the License.
#

module Fluent
require 'json'
require 'json'

require 'fluent/config/error'
require 'fluent/configurable'

module Fluent
module Config
def self.size_value(str)
case str.to_s
Expand Down
14 changes: 8 additions & 6 deletions lib/fluent/config/v1_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
# limitations under the License.
#

module Fluent
module Config
require 'strscan'
require 'uri'

require 'strscan'
require 'fluent/config/error'
require 'fluent/config/literal_parser'
require 'fluent/config/element'
require 'fluent/config/error'
require 'fluent/config/basic_parser'
require 'fluent/config/literal_parser'
require 'fluent/config/element'

module Fluent
module Config
class V1Parser < LiteralParser
ELEMENT_NAME = /[a-zA-Z0-9_]+/

Expand Down
12 changes: 6 additions & 6 deletions lib/fluent/configurable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
# limitations under the License.
#

module Fluent
require 'fluent/config/configure_proxy'
require 'fluent/config/section'
require 'fluent/config/error'
require 'fluent/registry'
require 'fluent/plugin'
require 'fluent/config/configure_proxy'
require 'fluent/config/section'
require 'fluent/config/error'
require 'fluent/registry'
require 'fluent/plugin'

module Fluent
module Configurable
def self.included(mod)
mod.extend(ClassMethods)
Expand Down
21 changes: 15 additions & 6 deletions lib/fluent/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@
# limitations under the License.
#

module Fluent
require 'fluent/event_router'
require 'fluent/root_agent'
require 'fluent/time'
require 'fluent/system_config'
require 'socket'
require 'rubygems'

require 'msgpack'
require 'cool.io'

require 'fluent/config'
require 'fluent/event'
require 'fluent/event_router'
require 'fluent/root_agent'
require 'fluent/time'
require 'fluent/system_config'
require 'fluent/plugin'

module Fluent
class EngineClass
def initialize
@root_agent = nil
Expand All @@ -35,7 +44,7 @@ def initialize

@msgpack_factory = MessagePack::Factory.new
@msgpack_factory.register_type(Fluent::EventTime::TYPE, Fluent::EventTime)
@system_config = SystemConfig.new({})
@system_config = SystemConfig.new
end

MATCH_CACHE_SIZE = 1024
Expand Down
2 changes: 2 additions & 0 deletions lib/fluent/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# limitations under the License.
#

require 'fluent/engine'

module Fluent
class EventStream
include Enumerable
Expand Down
6 changes: 4 additions & 2 deletions lib/fluent/event_router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
module Fluent
require 'fluent/match'

require 'fluent/match'
require 'fluent/event'

module Fluent
#
# EventRouter is responsible to route events to a collector.
#
Expand Down
6 changes: 6 additions & 0 deletions lib/fluent/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
# limitations under the License.
#

require 'fluent/config'
require 'fluent/configurable'
require 'fluent/engine'
require 'fluent/event'
require 'fluent/log'

module Fluent
class Filter
include Configurable
Expand Down
6 changes: 4 additions & 2 deletions lib/fluent/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
# limitations under the License.
#

module Fluent
require 'fluent/registry'
require 'fluent/configurable'
require 'fluent/registry'
require 'fluent/mixin'

module Fluent
class Formatter
include Configurable

Expand Down
5 changes: 5 additions & 0 deletions lib/fluent/input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# limitations under the License.
#

require 'fluent/config'
require 'fluent/configurable'
require 'fluent/engine'
require 'fluent/log'

module Fluent
class Input
include Configurable
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/label.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# limitations under the License.
#

module Fluent
require 'fluent/agent'
require 'fluent/agent'

module Fluent
class Label < Agent
def initialize(name, opts = {})
super(opts)
Expand Down
5 changes: 4 additions & 1 deletion lib/fluent/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def initialize(out=STDERR, level=LEVEL_TRACE, opts={})
# TODO: This variable name is unclear so we should change to better name.
@threads_exclude_events = []

# Fluent::Engine requires Fluent::Log, so we must take that object lazily
@engine = Fluent.const_get('Engine')

if opts.has_key?(:suppress_repeated_stacktrace)
@suppress_repeated_stacktrace = opts[:suppress_repeated_stacktrace]
end
Expand Down Expand Up @@ -285,7 +288,7 @@ def event(level, args)
record[key] = record[key].inspect unless record[key].respond_to?(:to_msgpack)
}
record['message'] = message.dup
Engine.push_log_event("#{@tag}.#{level}", time.to_i, record)
@engine.push_log_event("#{@tag}.#{level}", time.to_i, record)
end

return time, message
Expand Down
Loading