api

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 17 Imported by: 6

Documentation

Index

Constants

View Source
const (
	StatusSuccess status = "success"
	StatusError   status = "error"
)

Variables

View Source
var BuildInfo = &ThanosVersion{
	Version:   version.Version,
	Revision:  version.Revision,
	Branch:    version.Branch,
	BuildUser: version.BuildUser,
	BuildDate: version.BuildDate,
	GoVersion: version.GoVersion,
}

Functions

func Respond

func Respond(w http.ResponseWriter, data interface{}, warnings []error)

func RespondError

func RespondError(w http.ResponseWriter, apiErr *ApiError, data interface{})

func SetCORS

func SetCORS(w http.ResponseWriter)

SetCORS enables cross-site script calls.

Types

type ApiError

type ApiError struct {
	Typ ErrorType
	Err error
}

func (*ApiError) Error

func (e *ApiError) Error() string

type ApiFunc

type ApiFunc func(r *http.Request) (interface{}, []error, *ApiError, func())

type BaseAPI

type BaseAPI struct {
	Now func() time.Time
	// contains filtered or unexported fields
}

func NewBaseAPI

func NewBaseAPI(logger log.Logger, disableCORS bool, flagsMap map[string]string) *BaseAPI

NewBaseAPI returns a new initialized BaseAPI type.

func (*BaseAPI) Register

func (api *BaseAPI) Register(r *route.Router, tracer opentracing.Tracer, logger log.Logger, ins extpromhttp.InstrumentationMiddleware, logMiddleware *logging.HTTPServerMiddleware)

Register registers the common API endpoints.

type ErrorType

type ErrorType string
const (
	ErrorNone     ErrorType = ""
	ErrorTimeout  ErrorType = "timeout"
	ErrorCanceled ErrorType = "canceled"
	ErrorExec     ErrorType = "execution"
	ErrorBadData  ErrorType = "bad_data"
	ErrorInternal ErrorType = "internal"
)

type InstrFunc

type InstrFunc func(name string, f ApiFunc) http.HandlerFunc

func GetInstr

func GetInstr(
	tracer opentracing.Tracer,
	logger log.Logger,
	ins extpromhttp.InstrumentationMiddleware,
	logMiddleware *logging.HTTPServerMiddleware,
	disableCORS bool,
) InstrFunc

GetInstr returns a http HandlerFunc with the instrumentation middleware.

type RuntimeInfo

type RuntimeInfo struct {
	StartTime      time.Time `json:"startTime"`
	CWD            string    `json:"CWD"`
	GoroutineCount int       `json:"goroutineCount"`
	GOMAXPROCS     int       `json:"GOMAXPROCS"`
	GOGC           string    `json:"GOGC"`
	GODEBUG        string    `json:"GODEBUG"`
}

RuntimeInfo contains runtime information about Thanos.

type RuntimeInfoFn

type RuntimeInfoFn func() RuntimeInfo

RuntimeInfoFn returns updated runtime information about Thanos.

func GetRuntimeInfoFunc

func GetRuntimeInfoFunc(logger log.Logger) RuntimeInfoFn

type ThanosVersion

type ThanosVersion struct {
	Version   string `json:"version"`
	Revision  string `json:"revision"`
	Branch    string `json:"branch"`
	BuildUser string `json:"buildUser"`
	BuildDate string `json:"buildDate"`
	GoVersion string `json:"goVersion"`
}

ThanosVersion contains build information about Thanos.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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