MCPcopy
hub / github.com/benbjohnson/litestream / NewServer

Function NewServer

server.go:64–95  ·  view source on GitHub ↗

NewServer creates a new Server instance.

(store *Store)

Source from the content-addressed store, hash-verified

62
63// NewServer creates a new Server instance.
64func NewServer(store *Store) *Server {
65 ctx, cancel := context.WithCancel(context.Background())
66 s := &Server{
67 store: store,
68 SocketPerms: 0600,
69 ctx: ctx,
70 cancel: cancel,
71 logger: slog.Default().With(LogKeySystem, LogSystemServer),
72 }
73
74 mux := http.NewServeMux()
75 mux.HandleFunc("POST /start", s.handleStart)
76 mux.HandleFunc("POST /stop", s.handleStop)
77 mux.HandleFunc("GET /txid", s.handleTXID)
78 mux.HandleFunc("POST /register", s.handleRegister)
79 mux.HandleFunc("POST /unregister", s.handleUnregister)
80 mux.HandleFunc("POST /sync", s.handleSync)
81 mux.HandleFunc("GET /list", s.handleList)
82 mux.HandleFunc("GET /info", s.handleInfo)
83 mux.HandleFunc("GET /debug/sync-status", s.handleSyncStatus)
84
85 // pprof endpoints
86 mux.HandleFunc("GET /debug/pprof/", pprof.Index)
87 mux.HandleFunc("GET /debug/pprof/cmdline", pprof.Cmdline)
88 mux.HandleFunc("GET /debug/pprof/profile", pprof.Profile)
89 mux.HandleFunc("GET /debug/pprof/symbol", pprof.Symbol)
90 mux.HandleFunc("GET /debug/pprof/trace", pprof.Trace)
91
92 s.httpServer = &http.Server{Handler: mux}
93
94 return s
95}
96
97// Start begins listening for control connections.
98func (s *Server) Start() error {

Callers 9

TestServer_HandleInfoFunction · 0.92
TestServer_HandleListFunction · 0.92
TestServer_HandleStartFunction · 0.92
TestServer_HandleStopFunction · 0.92
TestServer_HandleSyncFunction · 0.92
RunMethod · 0.92

Calls

no outgoing calls

Tested by 8

TestServer_HandleInfoFunction · 0.74
TestServer_HandleListFunction · 0.74
TestServer_HandleStartFunction · 0.74
TestServer_HandleStopFunction · 0.74
TestServer_HandleSyncFunction · 0.74