session consumer로 교체
This commit is contained in:
23
main.go
23
main.go
@ -4,13 +4,15 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"repositories.action2quare.com/ayo/gocommon/flagx"
|
||||
"repositories.action2quare.com/ayo/gocommon/wshandler"
|
||||
"repositories.action2quare.com/ayo/tavern/core"
|
||||
|
||||
common "repositories.action2quare.com/ayo/gocommon"
|
||||
"repositories.action2quare.com/ayo/gocommon"
|
||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||
"repositories.action2quare.com/ayo/gocommon/session"
|
||||
)
|
||||
|
||||
var prefix = flagx.String("prefix", "", "")
|
||||
@ -20,11 +22,24 @@ func main() {
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
var config core.TavernConfig
|
||||
if err := common.LoadConfig(&config); err != nil {
|
||||
if err := gocommon.LoadConfig(&config); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
wsh, err := wshandler.NewWebsocketHandler()
|
||||
if len(config.SessionStorage) == 0 {
|
||||
panic("maingate_session_storage is missing")
|
||||
}
|
||||
|
||||
if config.SessionTTL == 0 {
|
||||
config.SessionTTL = 3600
|
||||
}
|
||||
|
||||
consumer, err := session.NewConsumer(ctx, config.SessionStorage, time.Duration(config.SessionTTL)*time.Second)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
wsh, err := wshandler.NewWebsocketHandler(consumer)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -35,7 +50,7 @@ func main() {
|
||||
serveMux := http.NewServeMux()
|
||||
wsh.RegisterHandlers(serveMux, *prefix)
|
||||
tv.RegisterHandlers(ctx, serveMux, *prefix)
|
||||
server := common.NewHTTPServer(serveMux)
|
||||
server := gocommon.NewHTTPServer(serveMux)
|
||||
logger.Println("tavern is started")
|
||||
wsh.Start(ctx)
|
||||
server.Start()
|
||||
|
||||
Reference in New Issue
Block a user