api

package
v0.0.0-...-7cb1dad Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HealthEndpoint   = "/healthz"
	ReadyEndpoint    = "/readyz"
	SwaggerEndpoint  = "/swagger/*any"
	ApiV1BasePath    = "/api/v1"
	MetricsEndpoint  = "/metrics"
	InfoEndpoint     = "/info"
	RabbitMQEndpoint = "api/queues/%2F/"
	DefaultUser      = "guest"
	DefaultPassword  = "guest"
)

Constants for common endpoint paths

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

type Api struct {
	MgtUrl    string
	QueueName string
	Port      int

	UserName string
	Password string
	// contains filtered or unexported fields
}

Api provides server configuration details and handlers

func NewApi

func NewApi(conf ApiConf) *Api

func (*Api) Info

func (a *Api) Info(c *gin.Context)

Info godoc @BasePath /api/v1 @Summary Info @Description provides server info @Tags example @Produce json @Success 200 {object} Info @Router /info [get]

func (*Api) Metrics

func (a *Api) Metrics(c *gin.Context)

Metrics godoc @BasePath /api/v1 @Summary metrics @Description provides RabbitMQ metrics @Tags example @Accept json @Produce json @Success 200 {object} QueueInfo @Router /metrics [get]

func (*Api) Start

func (a *Api) Start(ctx context.Context, wg *sync.WaitGroup)

type ApiConf

type ApiConf struct {
	MgtUrl      string `yaml:"MgtUrl"`
	Port        int    `yaml:"Port"`
	CompileDate string
	Version     string
	LogLevel    int    `yaml:"LogLevel"`
	QueueName   string `yaml:"QueueName"`
	UserName    string `yaml:"UserName"`
	Password    string `yaml:"Password"`
}

ApiConf Define configuration for the API, using yaml tagged fields for configuration parsing

type Info

type Info struct {
	CompileDate string `json:"compile_date"`
	Version     string `json:"version"`
	LogLevel    string `json:"log_level"`
	Date        string `json:"date"`
}

Info provides metadata about the server

type QueueInfo

type QueueInfo struct {
	Messages               int `json:"messages"`
	MessagesReady          int `json:"messages_ready"`
	MessagesUnacknowledged int `json:"messages_unacknowledged"`
}

QueueInfo represents the JSON structure returned by RabbitMQ API

Jump to

Keyboard shortcuts

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