Added base worker file

This commit is contained in:
Valentin Popov 2025-05-05 23:14:27 +00:00
parent f43e2630a2
commit cf3c2ddb19
No known key found for this signature in database
GPG Key ID: AE3CE523DAAA8401

39
cmd/worker/main.go Normal file
View File

@ -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)
}
}