Cronコネクタ
Cronコネクタは、cron式に基づいてデータリリースをスケジュールします。
コネクタタイプ: MeddleCron
Defaultモード
Section titled “Defaultモード”スケジュールされた時間にすべての蓄積されたデータをリリース:
{ "type": "MeddleCron", "config": { "mode": "Default", "expression": "0 */5 * * * *", "maxRetained": 100, "timezone": "Asia/Tokyo" }}Unique Keyモード
Section titled “Unique Keyモード”リリース前にキーでデータを重複排除:
{ "type": "MeddleCron", "config": { "mode": "UniqueKey", "expression": "0 0 * * * *", "uniqueKey": "sensor_id", "maxRetained": 1000 }}cron式の形式
Section titled “cron式の形式”形式:秒 分 時 日 月 曜日
0 */5 * * * * 5分ごと0 0 * * * * 毎時0 0 0 * * * 毎日深夜0 30 9 * * 1-5 平日の9:300 0 12 * * 0 日曜日の正午0 0 */6 * * * 6時間ごと0 15 10 * * * 毎日10:15フィールド値
Section titled “フィールド値”- 秒: 0-59
- 分: 0-59
- 時: 0-23
- 日: 1-31
- 月: 1-12
- 曜日: 0-6(0 = 日曜日)
*- 任意の値*/n- n単位ごとn-m- nからmの範囲n,m- 特定の値
設定パラメータ
Section titled “設定パラメータ”- mode:
Default、UniqueKey、またはUniqueKeyKeepMissing - expression: cron式
- maxRetained: メモリに保持する最大ペイロード
- timezone: スケジュール用のタイムゾーン(例:“Asia/Tokyo”)
- uniqueKey: (UniqueKeyモード)重複排除に使用するフィールド
ユースケース
Section titled “ユースケース”1. 時間ごとのレポート
Section titled “1. 時間ごとのレポート”{ "type": "MeddleCron", "config": { "mode": "Default", "expression": "0 0 * * * *", "maxRetained": 1000, "timezone": "UTC" }}2. 日次バッチ処理
Section titled “2. 日次バッチ処理”{ "type": "MeddleCron", "config": { "mode": "UniqueKey", "expression": "0 0 0 * * *", "uniqueKey": "machine_id", "maxRetained": 5000 }}3. 営業時間のみ
Section titled “3. 営業時間のみ”{ "type": "MeddleCron", "config": { "mode": "Default", "expression": "0 0 9-17 * * 1-5", "maxRetained": 500, "timezone": "Asia/Tokyo" }}ベストプラクティス
Section titled “ベストプラクティス”- メモリの問題を防ぐために
maxRetainedを設定 - 重複データを避けるために
UniqueKeyモードを使用 - ユースケースに適したタイムゾーンを選択
- オンラインcron計算機で式をテスト