选项
选项表示指定类型的任何值的存储位置。选项是可变的。一个选项在其生命周期内可以保存不同的值。
以下是 Flux 语言中当前实现的内置选项列表
选项不是封闭的,这意味着可以在包和脚本中定义和使用新选项。更改包的选项值会更改任何其他包对该选项的所有引用的值。
now
now
选项是一个函数,它返回一个时间值,用作当前系统时间的代理。
// Query should execute as if the below time is the current system time
option now = () => 2006-01-02T15:04:05-07:00
task
task
选项调度 Flux 查询的执行。
option task = {
name: "foo", // Name is required.
every: 1h, // Task should be run at this interval.
offset: 10m, // Delay scheduling this task by this duration.
cron: "0 2 * * *", // Cron is a more sophisticated way to schedule. 'every' and 'cron' are mutually exclusive.
}
location
location
选项设置脚本中所有时间的默认时区。位置将给定时间的该位置使用的 UTC 偏移量映射。默认值是 timezone.utc
。
import "timezone"
// Set timezone to be 5 hours west of UTC
option location = timezone.fixed(offset: -5h)
// Set location to be America/Denver
option location = timezone.location(name: "America/Denver")
location
选项仅影响用于窗口化的边界,特别是在夏令时等时间偏移周围。它不会更改 _time
列中的时间戳,这些时间戳始终为 UTC。
此页是否对您有帮助?
感谢您的反馈!