From cf3c2ddb19b2a01903cfdb6ca1d5d1c397c5f6f3 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 5 May 2025 23:14:27 +0000 Subject: [PATCH] Added base worker file --- cmd/worker/main.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 cmd/worker/main.go diff --git a/cmd/worker/main.go b/cmd/worker/main.go new file mode 100644 index 0000000..afc56f8 --- /dev/null +++ b/cmd/worker/main.go @@ -0,0 +1,39 @@ +package main + +import ( + "database/sql" + "flag" + "log" + "time" + + _ "github.com/mattn/go-sqlite3" +) + +func main() { + // Command line flags + dbPath := flag.String("db", "data.db", "path to SQLite database") + pollInterval := flag.Duration("poll", 100*time.Millisecond, "polling interval") + flag.Parse() + + // Initialize database connection + db, err := sql.Open("sqlite3", *dbPath) + if err != nil { + log.Fatalf("Failed to open database: %v", err) + } + defer db.Close() + + // Test database connection + if err := db.Ping(); err != nil { + log.Fatalf("Failed to ping database: %v", err) + } + + log.Printf("Worker started with polling interval: %v", *pollInterval) + + // Main worker loop + for { + // TODO: Write code here + + // Sleep for the specified interval + time.Sleep(*pollInterval) + } +}