enable write ahead log
This commit is contained in:
11
main.go
11
main.go
@@ -81,12 +81,12 @@ type updateSummaryOptions struct {
|
|||||||
|
|
||||||
type state struct {
|
type state struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
db *sql.DB
|
|
||||||
metAPIUserAgent string
|
metAPIUserAgent string
|
||||||
genai *genai.Client
|
genai *genai.Client
|
||||||
template pageTemplate
|
template pageTemplate
|
||||||
|
|
||||||
usePlaceholder bool
|
db *sql.DB
|
||||||
|
dbMutex sync.Mutex
|
||||||
|
|
||||||
// summaries maps location keys to their latest weather summary
|
// summaries maps location keys to their latest weather summary
|
||||||
summaries sync.Map
|
summaries sync.Map
|
||||||
@@ -189,7 +189,6 @@ func startServer(port int) error {
|
|||||||
|
|
||||||
state := state{
|
state := state{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
db: db,
|
|
||||||
metAPIUserAgent: os.Getenv("MET_API_USER_AGENT"),
|
metAPIUserAgent: os.Getenv("MET_API_USER_AGENT"),
|
||||||
template: pageTemplate{
|
template: pageTemplate{
|
||||||
summary: summaryPageTemplate,
|
summary: summaryPageTemplate,
|
||||||
@@ -198,7 +197,8 @@ func startServer(port int) error {
|
|||||||
summaryChans: map[string]chan string{},
|
summaryChans: map[string]chan string{},
|
||||||
genai: genaiClient,
|
genai: genaiClient,
|
||||||
|
|
||||||
usePlaceholder: false,
|
db: db,
|
||||||
|
dbMutex: sync.Mutex{},
|
||||||
|
|
||||||
subscriptions: map[string][]*registeredSubscription{},
|
subscriptions: map[string][]*registeredSubscription{},
|
||||||
|
|
||||||
@@ -425,6 +425,9 @@ func initDB() (*sql.DB, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, err = db.Exec(`
|
_, err = db.Exec(`
|
||||||
|
PRAGMA journal_mode = WAL;
|
||||||
|
PRAGMA synchronous = NORMAL;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS subscriptions(
|
CREATE TABLE IF NOT EXISTS subscriptions(
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
locations TEXT NOT NULL,
|
locations TEXT NOT NULL,
|
||||||
|
Reference in New Issue
Block a user