summaryrefslogtreecommitdiff
path: root/spooler.go
diff options
context:
space:
mode:
Diffstat (limited to 'spooler.go')
-rw-r--r--spooler.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/spooler.go b/spooler.go
new file mode 100644
index 0000000..c0bc8a1
--- /dev/null
+++ b/spooler.go
@@ -0,0 +1,44 @@
+package main
+
+import (
+ "github.com/fsnotify/fsnotify"
+ "log"
+ "os"
+)
+
+// parse a request file and return a SCORSHmessage
+func parse_request(fname string) (SCORSHmsg, error) {
+
+ var ret SCORSHmsg
+ _, err := os.Open(fname)
+ if err != nil {
+ log.Printf("Unable to open file: %s\n", fname)
+ return ret, SCORSHErr(SCORSH_ERR_NO_FILE)
+ }
+
+ return ret, nil
+
+}
+
+func spooler(watcher *fsnotify.Watcher, worker chan SCORSHmsg) {
+
+ for {
+ select {
+ case event := <-watcher.Events:
+ if event.Op == fsnotify.Create {
+ msg, err := parse_request(event.Name)
+ if err != nil {
+ log.Printf("Invalid packet received. [%s]\n", err)
+ }
+ worker <- msg
+ }
+ case err := <-watcher.Errors:
+ log.Println("error:", err)
+ }
+ }
+}
+
+
+func main(){
+
+}