mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-21 13:30:54 +00:00
Let's start caching some of the backlog data on the server
This commit is contained in:
parent
8918b9ac3a
commit
ae1306387e
4 changed files with 214 additions and 7 deletions
|
@ -1 +1,89 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// this value is just docs right now
|
||||
var ServerInitiatedCommands = []string{
|
||||
/// Global updates & notices
|
||||
"update_news", // timecache:global
|
||||
"message", // timecache:global
|
||||
"reload_ff", // timecache:global
|
||||
|
||||
/// Emote updates
|
||||
"reload_badges", // timecache:global
|
||||
"set_badge", // timecache:multichat
|
||||
"reload_set", // timecache:multichat
|
||||
"load_set", // TODO what are the semantics of this?
|
||||
|
||||
/// User auth
|
||||
"do_authorize", // nocache:single
|
||||
|
||||
/// Channel data
|
||||
// extra emote sets included in the chat
|
||||
"follow_sets", // mustcache:chat
|
||||
// extra follow buttons below the stream
|
||||
"follow_buttons", // mustcache:watching
|
||||
// SRL race data
|
||||
"srl_race", // cachelast:watching
|
||||
|
||||
/// Chatter/viewer counts
|
||||
"chatters", // cachelast:watching
|
||||
"viewers", // cachelast:watching
|
||||
}
|
||||
var _ = ServerInitiatedCommands
|
||||
|
||||
type BacklogCacheType int
|
||||
|
||||
const (
|
||||
// This is not a cache type.
|
||||
CacheTypeInvalid BacklogCacheType = iota
|
||||
// This message cannot be cached.
|
||||
CacheTypeNever
|
||||
// Save the last 24 hours of this message.
|
||||
// If a client indicates that it has reconnected, replay the messages sent after the disconnect.
|
||||
CacheTypeTimestamps
|
||||
// Save only the last copy of this message, and always send it when the backlog is requested.
|
||||
CacheTypeLastOnly
|
||||
// Save this backlog data to disk with its timestamp.
|
||||
// Send it when the backlog is requested, or after a reconnect if it was updated.
|
||||
CacheTypePersistent
|
||||
)
|
||||
|
||||
type MessageTargetType int
|
||||
|
||||
const (
|
||||
// This is not a message target.
|
||||
MsgTargetTypeInvalid MessageTargetType = iota
|
||||
// This message is targeted to a single TODO(user or connection)
|
||||
MsgTargetTypeSingle
|
||||
// This message is targeted to all users in a chat
|
||||
MsgTargetTypeChat
|
||||
// This message is targeted to all users in multiple chats
|
||||
MsgTargetTypeMultichat
|
||||
// This message is targeted to all users watching a stream
|
||||
MsgTargetTypeWatching
|
||||
// This message is sent to all FFZ users.
|
||||
MsgTargetTypeGlobal
|
||||
)
|
||||
|
||||
// Returned by BacklogCacheType.UnmarshalJSON()
|
||||
var ErrorUnrecognizedCacheType = errors.New("Invalid value for cachetype")
|
||||
|
||||
// Returned by MessageTargetType.UnmarshalJSON()
|
||||
var ErrorUnrecognizedTargetType = errors.New("Invalid value for message target")
|
||||
|
||||
// note: see types.go for methods on these
|
||||
|
||||
func HBackendSaveBacklog(w http.ResponseWriter, r *http.Request) {
|
||||
formData, err := UnsealRequest(r.Form)
|
||||
if err != nil {
|
||||
w.WriteHeader(403)
|
||||
fmt.Fprintf(w, "Error: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue