The timer
plugin helper manages event timers.
Here is an example:
require 'fluent/plugin/input'​module Fluent::Pluginclass ExampleInput < InputFluent::Plugin.register_input('example', self)​# 1. Load timer helperhelpers :timer​# Omit `configure`, `shutdown` and other plugin APIs​def startsuper​# 2. Execute timer with unique name and second unit intervaltimer_execute(:example_timer, 10) {# ...}endendend
The launched timer is managed by the plugin helper. No need of timer shutdown code in plugin's shutdown
method. The plugin shutdowns the launched timers automatically.
This method executes the timer with the given parameters and routine.
title
: unique symbol value
interval
: second unit integer
/float
value.
repeat
: true
/false
(default: true
). If false
, timer is one-shot.
Code examples:
# Pass block directly. block is executed in 10 second interval.timer_execute(:example_timer, 10) {# ...}​# Pass block with existing method. block is executed in 5 second and one-shot.timer_execute(:example_timer_run, 5s, repeat: false, &method(:run))def run# ...end
​out_forward
​
​in_monitor_agent
​
​in_sample
​
If this article is incorrect or outdated, or omits critical information, please let us know. Fluentd is an open-source project under Cloud Native Computing Foundation (CNCF). All components are available under the Apache 2 License.