SimpleApp

Started work on the actual stuff
Gave up on Valkey (for right now)
This commit is contained in:
Caleb Gardner
2024-06-16 06:46:44 -05:00
parent 7f9de3f025
commit 7b15aab7ec
8 changed files with 77 additions and 27 deletions
+24
View File
@@ -14,3 +14,27 @@ type ExtendedApp interface {
// Alternatively, use Backend.HandleFunc for more customizability
Extension(http.ResponseWriter, *http.Request)
}
type simpleApp struct {
countTab CountTable
crashTab CrashTable
appID string
}
func NewSimpleApp(appID string, countTable CountTable, crashTable CrashTable) App {
return &simpleApp{
appID: appID,
countTab: countTable,
crashTab: crashTable,
}
}
func (s *simpleApp) AppID() string {
return s.appID
}
func (s *simpleApp) CountTable() CountTable {
return s.countTab
}
func (s *simpleApp) CrashTable() CrashTable {
return s.crashTab
}
+4
View File
@@ -76,6 +76,10 @@ func (b *Backend) cleanupLoop() {
}
}
func (b *Backend) ServeHTTP(w http.ResponseWriter, r *http.Request) {
b.m.ServeHTTP(w, r)
}
func getDate(t time.Time) int {
return (t.Year() * 10000) + (int(t.Month()) * 100) + t.Day()
}
+1 -16
View File
@@ -1,23 +1,8 @@
package backend
package backend_test
import (
"fmt"
"testing"
"time"
"github.com/google/uuid"
)
func TestStuff(t *testing.T) {
for i := 0; i < 50; i++ {
go func() {
id, err := uuid.NewV7()
if err != nil {
fmt.Println(err)
}
fmt.Println(id.String())
}()
}
time.Sleep(3 * time.Second)
t.Fatal("end")
}
+6
View File
@@ -0,0 +1,6 @@
package db
/*
TODO
I don't like SQL, lol.
*/
+11 -1
View File
@@ -1 +1,11 @@
package db
package db
/*
TODO
Currently there isn't a clean way to implement this (as far as I can tell).
valkey-go relies on an internal library for it's command builder, which makes it impossible to
use properly for generics without manually writing out the Index command. I could probably do this, but
it's a pain.
valkey-go does have a Generic Object Mapping library (valkey-go/om), but it requires a Version field
on every struct which would be confusing if I did add it to all my structs and Go doesn't allow anonymous generics inside structs
*/