Feat: add sse broker

This commit is contained in:
Grail Finder
2025-05-03 13:18:51 +03:00
parent 8d85d0612c
commit 0fbc106f9a
5 changed files with 140 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package handlers
import (
"context"
"encoding/json"
"golias/models"
)
@ -9,6 +10,18 @@ func createRoom(ctx context.Context, req *models.RoomReq) (*models.Room, error)
return nil, nil
}
func getRoomByID(roomID string) (*models.Room, error) {
roomBytes, err := memcache.Get(models.CacheRoomPrefix + roomID)
if err != nil {
return nil, err
}
resp := &models.Room{}
if err := json.Unmarshal(roomBytes, &resp); err != nil {
return nil, err
}
return resp, nil
}
// context
func getRoomIDFromCtx(ctx context.Context) string {
id, _ := ctx.Value(models.CtxRoomIDKey).(string)