feat(backend): added compression threshold to start request

This commit is contained in:
Alexander Zavorotynskiy 2023-04-11 11:37:59 +02:00 committed by Delirium
parent 33fbdb149f
commit 05e47e978b
3 changed files with 21 additions and 15 deletions

View file

@ -176,13 +176,14 @@ func (e *Router) startSessionHandlerWeb(w http.ResponseWriter, r *http.Request)
e.addBeaconSize(tokenData.ID, p.BeaconSize)
ResponseWithJSON(w, &StartSessionResponse{
Token: e.services.Tokenizer.Compose(*tokenData),
UserUUID: userUUID,
SessionID: strconv.FormatUint(tokenData.ID, 10),
ProjectID: strconv.FormatUint(uint64(p.ProjectID), 10),
BeaconSizeLimit: e.getBeaconSize(tokenData.ID),
StartTimestamp: int64(flakeid.ExtractTimestamp(tokenData.ID)),
Delay: tokenData.Delay,
Token: e.services.Tokenizer.Compose(*tokenData),
UserUUID: userUUID,
SessionID: strconv.FormatUint(tokenData.ID, 10),
ProjectID: strconv.FormatUint(uint64(p.ProjectID), 10),
BeaconSizeLimit: e.getBeaconSize(tokenData.ID),
CompressionThreshold: e.getCompressionThreshold(),
StartTimestamp: int64(flakeid.ExtractTimestamp(tokenData.ID)),
Delay: tokenData.Delay,
}, startTime, r.URL.Path, bodySize)
}

View file

@ -15,14 +15,15 @@ type StartSessionRequest struct {
}
type StartSessionResponse struct {
Timestamp int64 `json:"timestamp"`
StartTimestamp int64 `json:"startTimestamp"`
Delay int64 `json:"delay"`
Token string `json:"token"`
UserUUID string `json:"userUUID"`
SessionID string `json:"sessionID"`
ProjectID string `json:"projectID"`
BeaconSizeLimit int64 `json:"beaconSizeLimit"`
Timestamp int64 `json:"timestamp"`
StartTimestamp int64 `json:"startTimestamp"`
Delay int64 `json:"delay"`
Token string `json:"token"`
UserUUID string `json:"userUUID"`
SessionID string `json:"sessionID"`
ProjectID string `json:"projectID"`
BeaconSizeLimit int64 `json:"beaconSizeLimit"`
CompressionThreshold int64 `json:"compressionThreshold"`
}
type NotStartedRequest struct {

View file

@ -66,6 +66,10 @@ func (e *Router) getBeaconSize(sessionID uint64) int64 {
return e.cfg.BeaconSizeLimit
}
func (e *Router) getCompressionThreshold() int64 {
return 20000
}
func (e *Router) clearBeaconSizes() {
for {
time.Sleep(time.Minute * 2)