This repository contains GO libraries used in the different components of Perses.
This set of libraries aims to provide a way:
- to handle processes management with graceful stop
- to define an HTTP API
- to handle the configuration
Note: These libraries are mainly designed to ease the development of Perses. As it is still a beta, breaking change can happen between two releases. But as there is nothing really specific to Perses itself, you can use it at your own risk.
Here's a short description about what each package provides:
- app: provides a runner that starts an application (usually with an HTTP API) and its tasks, and stops them gracefully when the process receives SIGINT or SIGTERM.
- async: provides an Async/Await implementation, and the interfaces
SimpleTaskandTaskto implement a long-running task. The subpackage async/taskhelper executes a task once, periodically or according to a cron schedule. - config: provides a config resolver that reads the configuration from a YAML file and/or from the environment variables, verifies it, and can notify the changes of the file.
- echo: provides a builder that helps to manage middlewares, apis and help to start an HTTP or HTTPS server (based
on echo) with a context management, a
/metricsendpoint and the access logs. The subpackage echo/middleware provides the logger and the metrics middlewares used by default. - file: provides a way to watch a file and to be notified when it changes, including when it is a Kubernetes ConfigMap or Secret.
- logrus: provides a builder that configures the global logrus logger (level, format and method trace).
- otel: provides a builder that creates the OpenTelemetry tracer provider, registered globally when the application starts and shut down when it stops.
- set: provides a generic set, that can be marshalled to and unmarshalled from JSON and YAML as a sorted list.
- slices: provides utility methods to manipulate slices (mostly slices of string)
The packages app, echo and logrus read their default configuration from command-line flags. These flags
must be registered before calling flag.Parse, with one of these functions:
app.InitFlagregisters all of them.logrus.InitFlagregisters the flags--log.*, like--log.leveland--log.format.echo.InitFlagregisters the flags configuring the HTTP server, like--web.listen-address, and the HTTPS server, like--web.tls-cert-fileand--web.tls-key-file.echo.InitTelemetryPathFlagregisters the flag--web.telemetry-path.
The description of each flag is printed with --help.