Class: Fluent::Plugin::LabelRouterOutput::Route
- Inherits:
-
Object
- Object
- Fluent::Plugin::LabelRouterOutput::Route
- Defined in:
- lib/fluent/plugin/out_label_router.rb
Instance Method Summary collapse
- #emit(tag, time, record) ⇒ Object
- #emit_es(tag, es) ⇒ Object
-
#initialize(selector, namespace, tag, router) ⇒ Route
constructor
A new instance of Route.
- #match?(labels, namespace) ⇒ Boolean
- #match_labels(input, match) ⇒ Object
Constructor Details
#initialize(selector, namespace, tag, router) ⇒ Route
Returns a new instance of Route.
46 47 48 49 50 51 |
# File 'lib/fluent/plugin/out_label_router.rb', line 46 def initialize(selector, namespace, tag, router) @router = router @selector = selector @namespace = namespace @tag = tag end |
Instance Method Details
#emit(tag, time, record) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/fluent/plugin/out_label_router.rb', line 58 def emit(tag, time, record) if @tag.empty? @router.emit(tag, time, record) else @router.emit(@tag, time, record) end end |
#emit_es(tag, es) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/fluent/plugin/out_label_router.rb', line 66 def emit_es(tag, es) if @tag.empty? @router.emit_stream(tag, es) else @router.emit_stream(@tag, es) end end |
#match?(labels, namespace) ⇒ Boolean
53 54 55 56 |
# File 'lib/fluent/plugin/out_label_router.rb', line 53 def match?(labels, namespace) # Match labels and namespace if defined return (match_labels(labels, @selector) and (@namespace == "" or namespace == @namespace)) end |
#match_labels(input, match) ⇒ Object
73 74 75 |
# File 'lib/fluent/plugin/out_label_router.rb', line 73 def match_labels(input, match) return (match.to_a - input.to_a).empty? end |