controller

package
v0.0.0-...-19e9a96 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHealthService

func RegisterHealthService(server *grpc.Server, healthService *HealthService)

RegisterHealthService 将健康检查服务注册到 gRPC 服务

func RegisterWithConsul

func RegisterWithConsul() error

Types

type ChatHandler

type ChatHandler struct {
	Service *service.ChatService
}

ChatHandler 封装了 ChatService

func NewChatHandler

func NewChatHandler(s *service.ChatService) *ChatHandler

NewChatHandler 创建一个新的 Handler

func (*ChatHandler) SSEStream

func (h *ChatHandler) SSEStream(c *gin.Context)

SSEStream godoc @Summary 创建SSE长链接 @Description 为指定用户ID创建Server-Sent Events长链接以实时接收消息 @Tags Chat @Produce text/event-stream @Param userID path string true "用户ID" @Success 200 {string} string "Event-Stream" @Router /stream/{userID} [get]

func (*ChatHandler) SendMessage

func (h *ChatHandler) SendMessage(c *gin.Context)

SendMessage godoc @Summary 发送消息 @Description 向指定用户发送一条消息 @Tags Chat @Accept json @Produce json @Param message body model.SendMessageRequest true "消息内容" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Router /send [post]

type Chatserver

type Chatserver struct {
	pb.UnimplementedChatServiceServer
	// contains filtered or unexported fields
}

func NewChatServer

func NewChatServer() *Chatserver

NewChatServer 创建并返回一个新的 Chatserver 实例

func (*Chatserver) ReceiveMessageStream

func (s *Chatserver) ReceiveMessageStream(req *pb.MessageStreamRequest, stream pb.ChatService_ReceiveMessageStreamServer) error

func (*Chatserver) SendMessage

func (*Chatserver) StartTimer

func (s *Chatserver) StartTimer(ctx context.Context)

type HealthService

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

HealthService 实现 grpc_health_v1.HealthServer 接口

func NewHealthService

func NewHealthService() *HealthService

NewHealthService 创建新的 HealthService 实例

func (*HealthService) Check

Check 方法实现

func (*HealthService) SetStatus

SetStatus 设置服务健康状态

func (*HealthService) Watch

Watch 方法实现(非必须,可返回未实现错误)

Jump to

Keyboard shortcuts

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