Removed manifest manager refresh + server improvements (#835)

* manifest: removed explicit refresh

Instead, content manager is exposing a revision counter that changes
on each mutation or index change. Manifest manager will be invalidated
whenever this is encountered.

* server: refactored initialization API

* server: added unit tests for repository server APIs (HTTP and REST)

* server: ensure we don't upload contents that already exist

This saves bandwidth, since the client can compute hash locally
and ask the server whether the object exists before starting the upload.
This commit is contained in:
Jarek Kowalski
2021-02-15 23:55:58 -08:00
committed by GitHub
parent a622f86aec
commit 675bf4e033
13 changed files with 383 additions and 67 deletions

View File

@@ -18,7 +18,6 @@
"github.com/pkg/errors"
prom "github.com/prometheus/client_golang/prometheus"
htpasswd "github.com/tg123/go-htpasswd"
"google.golang.org/grpc"
"github.com/kopia/kopia/internal/auth"
"github.com/kopia/kopia/internal/clock"
@@ -110,26 +109,11 @@ func runServer(ctx context.Context, rep repo.Repository) error {
var handler http.Handler = mux
if *serverStartGRPC {
grpcServer := grpc.NewServer(
grpc.MaxSendMsgSize(repo.MaxGRPCMessageSize),
grpc.MaxRecvMsgSize(repo.MaxGRPCMessageSize),
)
srv.RegisterGRPCHandlers(grpcServer)
log(ctx).Debugf("starting GRPC/HTTP server...")
httpServer.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.ProtoMajor == 2 && strings.Contains(r.Header.Get("Content-Type"), "application/grpc") {
grpcServer.ServeHTTP(w, r)
} else {
handler.ServeHTTP(w, r)
}
})
} else {
log(ctx).Debugf("starting HTTP-only server...")
httpServer.Handler = handler
handler = srv.GRPCRouterHandler(handler)
}
httpServer.Handler = handler
if *serverStartShutdownWhenStdinClosed {
log(ctx).Infof("Server will close when stdin is closed...")