handlers

package
v0.0.0-...-ebb372c Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VersionHandler

func VersionHandler(
	ctx context.Context, conn *sql.DB, _ map[string]string, _ ...string,
) (any, error)

VersionHandler handler func that returns the version of the database server.

Types

type ConnHandlerFunc

type ConnHandlerFunc func(
	ctx context.Context,
	conn *sql.DB,
	metricParams map[string]string,
	extraParams ...string,
) (any, error)

ConnHandlerFunc describes the signature all connection handler functions must have.

func QueryHandlerFunc

func QueryHandlerFunc(query string) ConnHandlerFunc

QueryHandlerFunc returns a handler function that will execute the specified query with arguments, formatting result rows as JSON.

type CustomQueries

type CustomQueries map[string]string

CustomQueries stores user defined custom queries.

func (CustomQueries) HandlerFunc

func (cq CustomQueries) HandlerFunc(
	ctx context.Context,
	conn *sql.DB,
	metricParams map[string]string,
	extraParams ...string,
) (any, error)

HandlerFunc handles a single metric request to execute a custom query.

func (CustomQueries) Load

func (cq CustomQueries) Load(customQueriesDirFS fs.FS, logr log.Logger) error

Load loads user defined custom queries form a config specified directory.

type HandlerFunc

type HandlerFunc func(
	metricParams map[string]string, extraParams ...string,
) (any, error)

HandlerFunc describes the signature all metric handler functions must have.

func WithJSONResponse

func WithJSONResponse(handler HandlerFunc) HandlerFunc

WithJSONResponse wraps a handler function, marshaling its response to a JSON object and returning it as string.

Jump to

Keyboard shortcuts

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