Class: Fluent::RouteOutput::Route

Inherits:
Object
  • Object
show all
Includes:
Configurable
Defined in:
lib/fluent/plugin/out_route.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ Route

Returns a new instance of Route.



36
37
38
39
40
41
42
43
# File 'lib/fluent/plugin/out_route.rb', line 36

def initialize(pattern)
  super()
  if !pattern || pattern.empty?
    pattern = '**'
  end
  @pattern = MatchPattern.create(pattern)
  @tag_cache = {}
end

Instance Attribute Details

#copyObject

TODO tag_transform regexp



34
35
36
# File 'lib/fluent/plugin/out_route.rb', line 34

def copy
  @copy
end

Instance Method Details

#configure(conf) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fluent/plugin/out_route.rb', line 49

def configure(conf)
  super
  if conf['copy']
    @copy = true
  end
  if @remove_tag_prefix
    @prefix_match = /^#{Regexp.escape(@remove_tag_prefix)}\.?/
  else
    @prefix_match = //
  end
  if @add_tag_prefix
    @tag_prefix = "#{@add_tag_prefix}."
  else
    @tag_prefix = ""
  end
end

#copy?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/fluent/plugin/out_route.rb', line 66

def copy?
  @copy
end

#emit(tag, es) ⇒ Object



70
71
72
73
74
75
76
77
78
79
# File 'lib/fluent/plugin/out_route.rb', line 70

def emit(tag, es)
  ntag = @tag_cache[tag]
  unless ntag
    ntag = tag.sub(@prefix_match, @tag_prefix)
    if @tag_cache.size < 1024  # TODO size limit
      @tag_cache[tag] = ntag
    end
  end
  Engine.emit_stream(ntag, es)
end

#match?(tag) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/fluent/plugin/out_route.rb', line 45

def match?(tag)
  @pattern.match(tag)
end