server

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHTTPPort     = 80
	DefaultHTTPSPort    = 443
	DefaultAdminPort    = 8080
	ReadTimeout         = 15 * time.Second
	WriteTimeout        = 15 * time.Second
	IdleTimeout         = 60 * time.Second
	TLSMinVersion       = tls.VersionTLS12
	ShutdownGracePeriod = 30 * time.Second
	DefaultLogName      = "service_default"
)

default configurations

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server encapsulates all the components and configurations required to run the Terraster server. Manages HTTP/HTTPS servers, health checkers, admin APIs, TLS configurations, and service pools.

func NewServer

func NewServer(
	srvCtx context.Context,
	errChan chan<- error,
	cfg *config.Config,
	apiCfg *config.APIConfig,
	authSrvc *auth_service.AuthService,
	zLog *zap.Logger,
	logManager *logger.LoggerManager,
) (*Server, error)

Sets up health checkers for each service, initializes the admin API, setup service log (if any) and prepares the server for startup.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down all running servers, including the admin server and all service servers. Also stops all health checkers and waits for all goroutines to finish within the provided context's deadline.

func (*Server) Start

func (s *Server) Start() error

Start initializes and starts all configured HTTP/HTTPS servers along with the admin server. It sets up TLS configurations, loads certificates, and begins listening for incoming requests. Also starts all health checkers in separate goroutines. Returns an error if any server fails to start.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL