github.com/iDigitalFlame/xmt@v0.5.4/device/daemon.go (about) 1 // Copyright (C) 2020 - 2023 iDigitalFlame 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation, either version 3 of the License, or 6 // any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program. If not, see <https://www.gnu.org/licenses/>. 15 // 16 17 package device 18 19 import ( 20 "context" 21 22 "github.com/iDigitalFlame/xmt/util/xerr" 23 ) 24 25 // ErrQuit is an error that can be returned from the DaemonFunction that 26 // will indicate a clean (non-error) break of the Daemon loop. 27 var ErrQuit = xerr.Sub("quit", 0x1F) 28 29 // DaemonFunc is a function type that can be used as a Daemon. This function 30 // should return nil to indicate a successful run or ErrQuit to break out of 31 // a 'DaemonTicker' loop. 32 // 33 // Any non-nil errors will be interpreted as exit code '1'. 34 type DaemonFunc func(context.Context) error