Add package docs and project vision/goals (#5169)

* Add goals/design vision to contributing doc
* Add barebones package documentation
This commit is contained in:
WithoutPants
2024-08-28 09:01:39 +10:00
committed by GitHub
parent 10341fba58
commit b7799df2a6
40 changed files with 96 additions and 6 deletions

View File

@@ -75,7 +75,8 @@ func (dir osFS) Open(name string) (fs.File, error) {
return os.DirFS(string(dir)).Open(name)
}
// Called at startup
// Initialize creates a new [Server] instance.
// It assumes that the [manager.Manager] instance has been initialised.
func Initialize() (*Server, error) {
mgr := manager.GetInstance()
cfg := mgr.Config
@@ -289,6 +290,9 @@ func Initialize() (*Server, error) {
return server, nil
}
// Start starts the server. It listens on the configured address and port.
// It calls ListenAndServeTLS if TLS is configured, otherwise it calls ListenAndServe.
// Calls to Start are blocked until the server is shutdown.
func (s *Server) Start() error {
logger.Infof("stash is listening on " + s.Addr)
logger.Infof("stash is running at " + s.displayAddress)
@@ -300,6 +304,7 @@ func (s *Server) Start() error {
}
}
// Shutdown gracefully shuts down the server without interrupting any active connections.
func (s *Server) Shutdown() {
err := s.Server.Shutdown(context.TODO())
if err != nil {