Browse Source

buffer persistence writes

master
Fusl 8 months ago
parent
commit
e756a64496
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      persistence.go

+ 6
- 2
persistence.go View File

@@ -2,6 +2,7 @@ package main


import ( import (
"archive/tar" "archive/tar"
"bufio"
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
@@ -27,7 +28,8 @@ type DumpChunkName struct {


func (that *GlobalBackfeedManager) HandleLoad(res http.ResponseWriter, req *http.Request) { func (that *GlobalBackfeedManager) HandleLoad(res http.ResponseWriter, req *http.Request) {
defer req.Body.Close() defer req.Body.Close()
tarReader := tar.NewReader(req.Body)
reqBuffer := bufio.NewReader(req.Body)
tarReader := tar.NewReader(reqBuffer)
existed := []string{} existed := []string{}
imported := []string{} imported := []string{}
recreate := req.URL.Query().Get("recreate") != "" recreate := req.URL.Query().Get("recreate") != ""
@@ -153,7 +155,9 @@ func (that *GlobalBackfeedManager) HandleDump(res http.ResponseWriter, req *http
WriteResponse(res, http.StatusNoContent, nil) WriteResponse(res, http.StatusNoContent, nil)
return return
} }
tarWriter := tar.NewWriter(res)
resBuf := bufio.NewWriterSize(res, 16*1024*1024)
defer resBuf.Flush()
tarWriter := tar.NewWriter(resBuf)
defer tarWriter.Close() defer tarWriter.Close()
pipe := that.BackfeedRedis.Pipeline() pipe := that.BackfeedRedis.Pipeline()
writeError := func(err error) { writeError := func(err error) {


Loading…
Cancel
Save