Some comments for own sake and some event handler stubs

This commit is contained in:
Marcel M. Otte 2021-11-03 22:34:55 +01:00
parent c5c3b88ce7
commit ccac2606b3
2 changed files with 48 additions and 1 deletions

View File

@ -7,8 +7,19 @@ import (
)
func main() {
// TODO: do proper signal handling!
fmt.Println("vim-go")
// load config
// find and load config
config.Load()
// init scheduler and check for next needed runs?
// start event loop
// accept event
// find associated device and it's backups
// mount device
// run backups, one after another if multiple
// unmount device
// end loop
}

View File

@ -1 +1,37 @@
package events
import "net"
var ls net.Listener
var done <-chan struct{}
func Init(socketPath string) {
ls, err = net.Listen(socketPath)
if err != nil {
panic(err)
}
}
func RunLoop() {
for {
go func() {
process()
}()
}
}
func process() {
client, err = ls.Accept()
if err != nil {
panic(err)
}
//TODO: rewrite to be safe regarding buffer length
buf := make([]byte, 2048)
nr, err := client.Read(buf)
if err != nil {
return
}
data := buf[0:nr]
}