http

package
v0.0.0-...-76447f0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Port defines the listening port of the HTTP server
	Port uint `yaml:"port"`
	// ShutdownTimeout defines the timeout to wait for the server to shut down gracefully
	ShutdownTimeout time.Duration `yaml:"shutdown_timeout"`
	// LogFolder defines the folder that contains the log files to read
	LogFolder string `yaml:"log_folder"`
	// BufferSize defines the size in bytes of the buffer used to read the log file
	BufferSize int `yaml:"buffer_size"`
	// MaxEvents defines the maximum number of events returned. That means the limit applies after filter is applied.
	MaxEvents uint `yaml:"max_events"`
}

Config contains the configuration for the HTTP server

func LoadConfig

func LoadConfig(data []byte, fs afero.Fs) (*Config, error)

LoadConfig loads the Config from the given bytes array, it sets defaults and verify that the config is valid. It returns an error if the config cannot be read or if it is invalid

type Server

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

Server is a HTTP server that implements the REST API to read events located in log files

func NewServer

func NewServer(config *Config, fs afero.Fs, parentLogger *zap.Logger) *Server

NewServer creates a Server with the given Config

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTP server on the port defined in Config

func (*Server) Stop

func (s *Server) Stop()

Stop stops the HTTP server. It waits up to the timeout defined by Config.ShutdownTimeout. After this delay, the HTTP server is stopped forcibly.

Jump to

Keyboard shortcuts

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