diff options
author | KatolaZ <katolaz@freaknet.org> | 2017-07-15 01:35:36 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2017-07-15 01:35:36 +0100 |
commit | 74f8a74ecf8284fd4182cabab797f17bb18e7032 (patch) | |
tree | fccf6ded5d4a894b5863039b99ce977023bd0f79 /spooler.go | |
parent | 726b399e4747032a3d052339cd62c57ae5b6767c (diff) |
Added Makefile -- gofmt
Diffstat (limited to 'spooler.go')
-rw-r--r-- | spooler.go | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -6,15 +6,14 @@ import ( "github.com/go-yaml/yaml" "io/ioutil" "log" -// "time" + // "time" ) // parse a request file and return a SCORSHmessage func parse_request(fname string, msg *SCORSHmsg) error { - debug.log("[parse_request] message at start: %s\n", msg) - + data, err := ioutil.ReadFile(fname) if err != nil { log.Printf("Unable to open file: %s\n", fname) @@ -22,10 +21,9 @@ func parse_request(fname string, msg *SCORSHmsg) error { } debug.log("[parse_request] file contains: \n%s\n", data) - + debug.log("[parse_request] reading message from file: %s\n", fname) - - + err = yaml.Unmarshal([]byte(data), msg) if err != nil { return fmt.Errorf("Error parsing message: %s", err) @@ -34,14 +32,13 @@ func parse_request(fname string, msg *SCORSHmsg) error { return nil } - func spooler(watcher *fsnotify.Watcher, worker chan SCORSHmsg) { log.Println("Spooler started correctly") var msg *SCORSHmsg msg = new(SCORSHmsg) - + for { select { case event := <-watcher.Events: @@ -61,7 +58,6 @@ func spooler(watcher *fsnotify.Watcher, worker chan SCORSHmsg) { } } - func StartSpooler(master *SCORSHmaster) error { watcher, err := fsnotify.NewWatcher() @@ -74,8 +70,8 @@ func StartSpooler(master *SCORSHmaster) error { if err != nil { return fmt.Errorf("Error adding folder: %s\n", err) } - + go spooler(watcher, master.Spooler) - + return nil } |