MCPcopy
hub / github.com/garethgeorge/backrest / runSyncAPIWithCtx

Function runSyncAPIWithCtx

internal/api/syncapi/syncapi_test.go:685–717  ·  view source on GitHub ↗
(ctx context.Context, peer *peerUnderTest, bindAddr string)

Source from the content-addressed store, hash-verified

683}
684
685func runSyncAPIWithCtx(ctx context.Context, peer *peerUnderTest, bindAddr string) {
686 mux := http.NewServeMux()
687 syncHandler := NewBackrestSyncHandler(peer.manager)
688 mux.Handle(v1syncconnect.NewBackrestSyncServiceHandler(syncHandler))
689
690 server := &http.Server{
691 Addr: bindAddr,
692 Handler: h2c.NewHandler(mux, &http2.Server{}), // h2c is HTTP/2 without TLS for grpc-connect support.
693 }
694
695 var wg sync.WaitGroup
696
697 go func() {
698 <-ctx.Done()
699 server.Shutdown(context.Background())
700 }()
701
702 wg.Add(1)
703 go func() {
704 if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
705 panic(err)
706 }
707 wg.Done()
708 }()
709
710 wg.Add(1)
711 go func() {
712 peer.manager.RunSync(ctx)
713 wg.Done()
714 }()
715
716 wg.Wait()
717}
718
719func startRunningSyncAPI(t *testing.T, peer *peerUnderTest, bindAddr string) {
720 t.Helper()

Callers 5

TestSyncMutationsFunction · 0.85
startRunningSyncAPIFunction · 0.85
TestFuzzOperationSyncFunction · 0.85

Calls 5

NewBackrestSyncHandlerFunction · 0.85
DoneMethod · 0.80
AddMethod · 0.65
RunSyncMethod · 0.45

Tested by

no test coverage detected