aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/main.go b/main.go
index 029bf84..9c94e6c 100644
--- a/main.go
+++ b/main.go
@@ -7,6 +7,7 @@ import (
"os"
"redisClone/pkg/commands"
"redisClone/pkg/core"
+ "redisClone/pkg/pubsub"
"strings"
"time"
)
@@ -14,7 +15,7 @@ import (
var db core.RedisDB
-var hub Hub
+var hub pubsub.Hub
type baseHandlerFunc func([]string)interface{}
type connectionHandlerFunc func(net.Conn, []string)
@@ -45,9 +46,6 @@ var baseCommandRegistry = map[string]baseHandlerFunc{
"LREM": handleLrem,
}
var connectionCommandRegistry = map[string]connectionHandlerFunc{
- "SUBSCRIBE": handleSubscribe,
- "UNSUBSCRIBE": handleUnsubscribe,
- "PUBLISH": handlePublish,
"PING": handlePing,
}
@@ -61,7 +59,7 @@ func main() {
}
}
db = core.RedisDB{Shards: shards}
- hub = Hub{Channels: make(map[string]map[net.Conn]struct{}),}
+ hub = pubsub.Hub{Channels: make(map[string]map[net.Conn]struct{}),}
go func() {
ticker := time.NewTicker(1 * time.Second)
@@ -98,7 +96,7 @@ func main() {
func handleConnection(conn net.Conn) {
defer func() {
- handleDisconnect(conn)
+ hub.HandleDisconnect(conn)
conn.Close()
}()
fmt.Println("Client connected:", conn.RemoteAddr())