From bdad774b1600d3520e2349e391097de20b1bbd8a Mon Sep 17 00:00:00 2001 From: wisplite Date: Thu, 26 Feb 2026 12:38:01 -0600 Subject: [PATCH] initial commit --- engine.go | 15 +++++++++++++++ go.mod | 11 +++++++++++ go.sum | 10 ++++++++++ reactivity/tracker.go | 13 +++++++++++++ reactivity/websocket.go | 1 + 5 files changed, 50 insertions(+) create mode 100644 engine.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 reactivity/tracker.go create mode 100644 reactivity/websocket.go diff --git a/engine.go b/engine.go new file mode 100644 index 0000000..4100c4b --- /dev/null +++ b/engine.go @@ -0,0 +1,15 @@ +package tether + +import ( + "github.com/wisplite/tether/reactivity" + "gorm.io/gorm" +) + +type Engine struct { + db *gorm.DB + channels map[string]*reactivity.Channel +} + +func NewEngine(db *gorm.DB) *Engine { + return &Engine{db: db, channels: make(map[string]*reactivity.Channel)} +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..843af08 --- /dev/null +++ b/go.mod @@ -0,0 +1,11 @@ +module github.com/wisplite/tether + +go 1.25.6 + +require ( + github.com/gorilla/websocket v1.5.3 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect + golang.org/x/text v0.34.0 // indirect + gorm.io/gorm v1.31.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..cdd24ad --- /dev/null +++ b/go.sum @@ -0,0 +1,10 @@ +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk= +golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA= +gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg= +gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs= diff --git a/reactivity/tracker.go b/reactivity/tracker.go new file mode 100644 index 0000000..d148453 --- /dev/null +++ b/reactivity/tracker.go @@ -0,0 +1,13 @@ +package reactivity + +import "github.com/gorilla/websocket" + +type Subscription struct { + ID string + Conn *websocket.Conn +} + +type Channel struct { + ID string + Subscriptions []*Subscription +} diff --git a/reactivity/websocket.go b/reactivity/websocket.go new file mode 100644 index 0000000..4d7eb49 --- /dev/null +++ b/reactivity/websocket.go @@ -0,0 +1 @@ +package reactivity