Documentation ¶
Index ¶
- func AddTagToRootScope(c *gin.Context, tags map[string]string)
- func CORSAllowAll(c *gin.Context)
- func GetInt64Param(c *gin.Context, key string, maxVal, defaultVal int64) (int64, error)
- func GetInt64Query(c *gin.Context, key string, maxVal, defaultVal int64) (int64, error)
- func GetPagenation(c *gin.Context, maxPageSize, defaultPageSize int64) (int64, int64, error)
- func GetUUIDParam(c *gin.Context, key string) (uuid.UUID, error)
- func ListenWithGracefulShutdown(ctx context.Context, log logrus.Ext1FieldLogger, router *gin.Engine, ...) error
- func SafeMetricsAdd(log logrus.Ext1FieldLogger, metric *ginmetrics.Metric, labelValues []string, ...)
- func SafeMetricsGauge(log logrus.Ext1FieldLogger, metric *ginmetrics.Metric, labelValues []string, ...)
- func SafeMetricsInc(log logrus.Ext1FieldLogger, metric *ginmetrics.Metric, labelValues []string)
- func SetupMetrics(otherRouter *gin.Engine, path, listen string, durations []float64) *ginmetrics.Monitor
- type Database
- type EthClient
- type HealthCheck
- type ServerConfig
- type StatusChecker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddTagToRootScope ¶
AddTagToRootScope adds tags to the root scope of the current request's Sentry hub.
func CORSAllowAll ¶
CORSAllowAll sets up the CORS headers to allow all origins, methods and headers.
func GetInt64Param ¶
GetInt64Param gets the int64 parameter from the gin context, and returns the value or the default value if the parameter is not set.
func GetInt64Query ¶
GetInt64Query gets the int64 query parameter from the gin context, and returns the value or the default value if the parameter is not set.
func GetPagenation ¶
GetPagenation takes the query parameters "page" and "pageSize" from the gin context, and returns the values or an error if the parameters are invalid. Defaults page to 0, and pageSize to defaultPageSize if not set. Returns page, pageSize, error
func GetUUIDParam ¶
GetUUIDParam gets the uuid parameter from the gin context Param call, and parses then returns the value or an error if the parameter is not set or invalid.
func ListenWithGracefulShutdown ¶
func ListenWithGracefulShutdown(ctx context.Context, log logrus.Ext1FieldLogger, router *gin.Engine, conf ServerConfig) error
ListenWithGracefulShutdown listens on the given address with the given gin router, and will shutdown gracefully when a SIGINT or SIGTERM signal is received. Also setups up a health check endpoint on the given path, which will be unhealthy when the server is shutting down.
func SafeMetricsAdd ¶
func SafeMetricsAdd(log logrus.Ext1FieldLogger, metric *ginmetrics.Metric, labelValues []string, value float64)
SafeMetricsAdd increased the given metric by value with the given label values, and logs an error if the increase fails. All parameters can safely be nil, if metric is nil, this function does nothing.
func SafeMetricsGauge ¶
func SafeMetricsGauge(log logrus.Ext1FieldLogger, metric *ginmetrics.Metric, labelValues []string, value float64)
SafeMetricsGauge sets the given metric to the given value with the given label values, and logs an error if the set fails.
func SafeMetricsInc ¶
func SafeMetricsInc(log logrus.Ext1FieldLogger, metric *ginmetrics.Metric, labelValues []string)
SafeMetricsInc increments the given metric with the given label values, and logs an error if the increment fails. All parameters can safely be nil, if metric is nil, this function does nothing.
func SetupMetrics ¶
func SetupMetrics(otherRouter *gin.Engine, path, listen string, durations []float64) *ginmetrics.Monitor
SetupMetrics sets up a ginmetrics.Monitor with the given parameters, will expose the metrics on the given path and listen on the given address.
Types ¶
type HealthCheck ¶
func NewHealthCheck ¶
func NewHealthCheck() *HealthCheck
func (*HealthCheck) Health ¶
func (h *HealthCheck) Health(c *gin.Context)
type ServerConfig ¶
type ServerConfig struct { ReadTimeout time.Duration `env:"READ_TIMEOUT" env-default:"5s"` ShutdownTimeout time.Duration `env:"SHUTDOWN_TIMEOUT" env-default:"15s"` Listen string `env:"LISTEN" env-default:":8080"` HealthCheckPath string `env:"HEALTH_CHECK_PATH" env-default:"/health"` }
func LoadServerConfigFromEnv ¶
func LoadServerConfigFromEnv() (ServerConfig, error)
type StatusChecker ¶
type StatusChecker struct {
// contains filtered or unexported fields
}
func NewStatusChecker ¶
func NewStatusChecker(log logrus.Ext1FieldLogger) *StatusChecker
func (*StatusChecker) AddDatabase ¶
func (sc *StatusChecker) AddDatabase(key string, db Database) error
func (*StatusChecker) AddEthClient ¶
func (sc *StatusChecker) AddEthClient(key string, ec EthClient) error
func (*StatusChecker) Check ¶
func (sc *StatusChecker) Check(c *gin.Context)