app

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

func New

func New(
	ctx context.Context,
	logger *logging.Logger,
	port string,
	staticDir string,
	shutdownTimeout time.Duration,
) *App

New creates and returns a new App instance with the provided dependencies. It initializes the HTTP server with default configuration and prepares it for handling requests.

Parameters:

  • ctx: The context for the application lifecycle
  • logger: A configured zap logger for application logging
  • port: The port on which the server will listen for incoming requests
  • staticDir: The directory containing static files to serve
  • shutdownTimeout: The duration to wait during shutdown before forcefully terminating

func (*App) LaunchServer

func (app *App) LaunchServer() error

LaunchServer starts the HTTP server and manages its lifecycle. It will run until either a server error occurs or the application context is cancelled. When the context is cancelled, it triggers a graceful shutdown.

Returns an error if the server fails to start or encounters an error while running.

func (*App) SetServerShutdownTimeout

func (app *App) SetServerShutdownTimeout(t time.Duration)

SetServerShutdownTimeout configures the duration the server will wait during shutdown before forcefully terminating connections.

Parameters:

  • t: The duration to wait during shutdown in nanoseconds

func (*App) ShutdownServer

func (app *App) ShutdownServer()

ShutdownServer attempts to gracefully shut down the HTTP server within the configured shutdown timeout duration. If graceful shutdown fails, it forces the server to close. The shutdown status is logged through the application logger.

Jump to

Keyboard shortcuts

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