http

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AckInput

type AckInput struct {
	QueueName string `path:"queue_name" maxLength:"1024" example:"user_indexing_queue" doc:"Name of the queue"`
	ID        uint64 `path:"id" example:"123" doc:"ID of the message"`
}

type AckOutput

type AckOutput struct {
	Status int
	Body   AckOutputBody
}

type AckOutputBody

type AckOutputBody struct {
	Status string `json:"status" example:"ACKNOWLEDGED" doc:"Status of the dequeue operation"`
	ID     string `json:"id" doc:"ID of the message"`
}

type CreateQueueInput

type CreateQueueInput struct {
	Body CreateQueueInputBody
}

type CreateQueueInputBody

type CreateQueueInputBody struct {
	Name string `json:"name" maxLength:"1024" example:"user_indexing_queue" doc:"Name of the queue"`
	Type string `json:"type" enum:"delayed,fair" example:"delayed" doc:"Type of the queue"`
}

type CreateQueueOutput

type CreateQueueOutput struct {
	Status int
	Body   CreateQueueOutputBody
}

type CreateQueueOutputBody

type CreateQueueOutputBody struct {
	Status string `json:"status" example:"CREATED" doc:"Status of the create operation"`
	Name   string `json:"name" maxLength:"1024" example:"user_indexing_queue" doc:"Name of the queue"`
	Type   string `json:"type" enum:"delayed,fair" example:"delayed" doc:"Type of the queue"`
}

type DeleteQueueInput

type DeleteQueueInput struct {
	QueueName string `path:"queue_name" maxLength:"1024" example:"user_indexing_queue" doc:"Name of the queue"`
}

type DeleteQueueOutput

type DeleteQueueOutput struct {
	Status int
	Body   DeleteQueueOutputBody
}

type DeleteQueueOutputBody

type DeleteQueueOutputBody struct {
	Status string `json:"status" example:"DELETED" doc:"Status of the delete operation"`
}

type DequeueInput

type DequeueInput struct {
	QueueName string `path:"queue_name" maxLength:"1024" example:"user_indexing_queue" doc:"Name of the queue"`
	Ack       bool   `query:"ack" example:"true" doc:"Acknowledge the message"`
}

type DequeueOutput

type DequeueOutput struct {
	Status int
	Body   DequeueOutputBody
}

type DequeueOutputBody

type DequeueOutputBody struct {
	Status   string `json:"status" example:"DEQUEUED" doc:"Status of the dequeue operation"`
	ID       string `json:"id" doc:"ID of the message"`
	Group    string `json:"group,omitempty" default:"default" example:"customer-1" doc:"Group of the message"`
	Priority int64  `json:"priority" minimum:"0" example:"60" doc:"Priority of the message"`
	Content  string `json:"content" example:"{\"user_id\": 1}" doc:"Content of the message"`
}

type EnqueueInput

type EnqueueInput struct {
	QueueName string `path:"queue_name" maxLength:"1024" example:"user_indexing_queue" doc:"Name of the queue"`
	Body      EnqueueInputBody
}

type EnqueueInputBody

type EnqueueInputBody struct {
	Group    string `json:"group,omitempty" default:"default" example:"customer-1" doc:"Group of the message"`
	Priority int64  `json:"priority" minimum:"0" example:"60" doc:"Priority of the message"`
	Content  string `json:"content" example:"{\"user_id\": 1}" doc:"Content of the message"`
}

type EnqueueOutput

type EnqueueOutput struct {
	Status int
	Body   EnqueueOutputBody
}

type EnqueueOutputBody

type EnqueueOutputBody struct {
	Status   string `json:"status" example:"ENQUEUED" doc:"Status of the enqueue operation"`
	ID       string `json:"id" doc:"ID of the message"`
	Group    string `json:"group,omitempty" default:"default" example:"customer-1" doc:"Group of the message"`
	Priority int64  `json:"priority" minimum:"0" example:"60" doc:"Priority of the message"`
	Content  string `json:"content" example:"{\"user_id\": 1}" doc:"Content of the message"`
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func (*Handler) Ack

func (h *Handler) Ack(ctx context.Context, input *AckInput) (*AckOutput, error)

func (*Handler) ConfigureMiddleware

func (h *Handler) ConfigureMiddleware(router *fiber.App)

func (*Handler) CreateQueue

func (h *Handler) CreateQueue(ctx context.Context, input *CreateQueueInput) (*CreateQueueOutput, error)

func (*Handler) DeleteQueue

func (h *Handler) DeleteQueue(ctx context.Context, input *DeleteQueueInput) (*DeleteQueueOutput, error)

func (*Handler) Dequeue

func (h *Handler) Dequeue(ctx context.Context, input *DequeueInput) (*DequeueOutput, error)

func (*Handler) Enqueue

func (h *Handler) Enqueue(ctx context.Context, input *EnqueueInput) (*EnqueueOutput, error)

func (*Handler) Join added in v0.1.11

func (h *Handler) Join(ctx context.Context, input *JoinInput) (*JoinOutput, error)

func (*Handler) Nack added in v0.2.4

func (h *Handler) Nack(ctx context.Context, input *NackInput) (*NackOutput, error)

func (*Handler) QueueInfo added in v0.2.0

func (h *Handler) QueueInfo(ctx context.Context, input *QueueInfoInput) (*QueueInfoOutput, error)

func (*Handler) Queues added in v0.2.0

func (h *Handler) Queues(ctx context.Context, input *QueuesInput) (*QueuesOutput, error)

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(api huma.API)

func (*Handler) UpdatePriority

func (h *Handler) UpdatePriority(ctx context.Context, input *UpdatePriorityInput) (*UpdatePriorityOutput, error)

type JoinInput added in v0.1.11

type JoinInput struct {
	Body struct {
		ID   string `json:"id" example:"node-0" doc:"ID of a node"`
		Addr string `json:"addr" example:"localhost:12001" doc:"IP address and a port of a service"`
	}
}

type JoinOutput added in v0.1.11

type JoinOutput struct {
	Body struct {
		ID   string `json:"id" example:"node-0" doc:"ID of a node"`
		Addr string `json:"addr" example:"localhost:12001" doc:"IP address and a port of a service"`
	}
}

type NackInput added in v0.2.4

type NackInput struct {
	QueueName string `path:"queue_name" maxLength:"1024" example:"user_indexing_queue" doc:"Name of the queue"`
	ID        uint64 `path:"id" example:"123" doc:"ID of the message"`
}

type NackOutput added in v0.2.4

type NackOutput struct {
	Status int
	Body   NackOutputBody
}

type NackOutputBody added in v0.2.4

type NackOutputBody struct {
	Status string `json:"status" example:"UNACKNOWLEDGED" doc:"Status of the dequeue operation"`
	ID     string `json:"id" doc:"ID of the message"`
}

type Node

type Node interface {
	Join(nodeID string, addr string) error
	PrometheusRegistry() prometheus.Registerer
	Leader() string
	IsLeader() bool
	GenerateID() uint64
	CreateQueue(queueType, queueName string) error
	DeleteQueue(queueName string) error
	GetQueues() []*queue.QueueInfo
	GetQueueInfo(queueName string) (*queue.QueueInfo, error)
	Enqueue(queueName string, group string, priority int64, content string) (*queue.Message, error)
	Dequeue(QueueName string, ack bool) (*queue.Message, error)
	Ack(QueueName string, id uint64) error
	Nack(QueueName string, id uint64) error
	GetByID(id uint64) (*queue.Message, error)
	UpdatePriority(queueName string, id uint64, priority int64) error
}

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(client *http.Client) *Proxy

func (*Proxy) Ack

func (p *Proxy) Ack(
	ctx context.Context,
	host string,
	queueName string,
	id uint64,
) (*AckOutputBody, huma.StatusError)

func (*Proxy) CreateQueue

func (p *Proxy) CreateQueue(
	ctx context.Context, host string, body *CreateQueueInputBody,
) (*CreateQueueOutputBody, huma.StatusError)

func (*Proxy) DeleteQueue

func (p *Proxy) DeleteQueue(
	ctx context.Context, host string, queueName string,
) (*DeleteQueueOutputBody, huma.StatusError)

func (*Proxy) Dequeue

func (p *Proxy) Dequeue(
	ctx context.Context, host string, queueName string, ack bool,
) (*DequeueOutputBody, huma.StatusError)

func (*Proxy) Enqueue

func (p *Proxy) Enqueue(ctx context.Context, host string, queueName string, body *EnqueueInputBody) (*EnqueueOutputBody, huma.StatusError)

func (*Proxy) Nack added in v0.2.4

func (p *Proxy) Nack(
	ctx context.Context,
	host string,
	queueName string,
	id uint64,
) (*NackOutputBody, huma.StatusError)

func (*Proxy) UpdatePriority

func (p *Proxy) UpdatePriority(
	ctx context.Context,
	host string,
	queueName string,
	id uint64,
	body *UpdatePriorityInputBody,
) (*UpdatePriorityOutputBody, huma.StatusError)

type QueueInfoInput added in v0.2.0

type QueueInfoInput struct {
	QueueName string `path:"queue_name" maxLength:"1024" example:"user_indexing_queue" doc:"Name of the queue"`
}

type QueueInfoOutput added in v0.2.0

type QueueInfoOutput struct {
	Status int
	Body   QueueInfoOutputBody
}

type QueueInfoOutputBody added in v0.2.0

type QueueInfoOutputBody struct {
	Name       string  `json:"name" maxLength:"1024" example:"user_indexing_queue" doc:"Name of the queue"`
	Type       string  `json:"type" enum:"delayed,fair" example:"delayed" doc:"Type of the queue"`
	EnqueueRPS float64 `json:"enqueue_rps" doc:"Rate of enqueued messages per second"`
	DequeueRPS float64 `json:"dequeue_rps" doc:"Rate of dequeued messages per second"`
	AckRPS     float64 `json:"ack_rps" doc:"Rate of acknowledged messages per second"`
	NackRPS    float64 `json:"nack_rps" doc:"Rate of unacknowledged messages per second"`
	Ready      int64   `json:"ready" doc:"Number of ready messages"`
	Unacked    int64   `json:"unacked" doc:"Number of unacknowledged messages"`
	Total      int64   `json:"total" doc:"Total number of messages"`
}

type QueueOutput added in v0.2.0

type QueueOutput struct {
	Name       string  `json:"name" maxLength:"1024" example:"user_indexing_queue" doc:"Name of the queue"`
	Type       string  `json:"type" enum:"delayed,fair" example:"delayed" doc:"Type of the queue"`
	EnqueueRPS float64 `json:"enqueue_rps" doc:"Rate of enqueued messages per second"`
	DequeueRPS float64 `json:"dequeue_rps" doc:"Rate of dequeued messages per second"`
	AckRPS     float64 `json:"ack_rps" doc:"Rate of acknowledged messages per second"`
	NackRPS    float64 `json:"nack_rps" doc:"Rate of unacknowledged messages per second"`
	Ready      int64   `json:"ready" doc:"Number of ready messages"`
	Unacked    int64   `json:"unacked" doc:"Number of unacknowledged messages"`
	Total      int64   `json:"total" doc:"Total number of messages"`
}

type QueuesInput added in v0.2.0

type QueuesInput struct {
}

type QueuesOutput added in v0.2.0

type QueuesOutput struct {
	Status int
	Body   QueuesOutputBody
}

type QueuesOutputBody added in v0.2.0

type QueuesOutputBody struct {
	Queues []QueueOutput `json:"queues"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service provides HTTP service.

func NewHttpService

func NewHttpService(config *config.Config, node Node, indexHtmlFS embed.FS, frontendFS embed.FS) *Service

New returns an uninitialized HTTP service.

func (*Service) Start

func (s *Service) Start() error

Start starts the service.

type UpdatePriorityInput

type UpdatePriorityInput struct {
	QueueName string `path:"queue_name" maxLength:"1024" example:"user_indexing_queue" doc:"Name of the queue"`
	ID        uint64 `path:"id" example:"123" doc:"ID of the message"`
	Body      UpdatePriorityInputBody
}

type UpdatePriorityInputBody

type UpdatePriorityInputBody struct {
	Priority int64 `json:"priority" minimum:"0" example:"60" doc:"Priority of the message"`
}

type UpdatePriorityOutput

type UpdatePriorityOutput struct {
	Status int
	Body   UpdatePriorityOutputBody
}

type UpdatePriorityOutputBody

type UpdatePriorityOutputBody struct {
	Status   string `json:"status" example:"ENQUEUED" doc:"Status of the enqueue operation"`
	ID       string `json:"id" doc:"ID of the message"`
	Priority int64  `json:"priority" minimum:"0" example:"60" doc:"Priority of the message"`
}

Jump to

Keyboard shortcuts

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