gin_gonic

package
v0.0.0-...-bdc8d50 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NormalModel 单副本时将 name 作为服务唯一 id
	NormalModel int8 = iota
	// RandomModel 多副本但不需要连接 nats、kafka 等有状态应用时,可使用 "name.uuid" 作为服务随机唯一 id。
	// 以 nats 为例,消息订阅时的 queueName(id.subject) 和 consumerName(subject.id) 需确保唯一且不变,
	// 否则 nats 不会推送服务上次离线期间的消息。会造成消息丢失现象。
	RandomModel
	// HostnameModel 在副本 hostname 确定或规范时(StatefulSet),"name.hostname" 可作为单副本或多副本有状态下的服务唯一 id,
	// 在 hostname 随机时(Deployment),不可作为单副本或多副本模式下的服务唯一 id。
	HostnameModel
	// DistributionModel 使用第三方服务分发多副本的服务器唯一 id TODO
	DistributionModel
)

Variables

This section is empty.

Functions

func Run

func Run(fn func(srv *Server))

Run .

func SetModel

func SetModel(m int8)

SetModel . NormalModel | RandomModel | HostnameModel | DistributionModel

Types

type Handler

type Handler func(ctx *hfwctx.Context)

Handler 业务处理

type Router

type Router struct {
	*gin.RouterGroup
}

Router .

func (*Router) DELETE

func (r *Router) DELETE(uri string, h Handler)

DELETE .

func (*Router) GET

func (r *Router) GET(uri string, h Handler)

GET .

func (*Router) NewRouterGroup

func (r *Router) NewRouterGroup(p string) *Router

NewRouterGroup .

func (*Router) POST

func (r *Router) POST(uri string, h Handler)

POST .

func (*Router) PUT

func (r *Router) PUT(uri string, h Handler)

PUT .

type Server

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

Server .

func (*Server) Lifecycle

func (srv *Server) Lifecycle(hooks ...*lifecycle.Hook)

Lifecycle .

func (*Server) Publish

func (srv *Server) Publish(topic string, v interface{}, opts ...func(o *broker.PublishOptions)) error

Publish 消息异步发布

func (*Server) RegisterRouter

func (srv *Server) RegisterRouter(fn func(r *Router))

RegisterRouter 注册路由

func (*Server) RegisterRouterGroup

func (srv *Server) RegisterRouterGroup(uri string, fn func(r *Router), handlers ...gin.HandlerFunc)

RegisterRouterGroup 注册路由组

func (*Server) Subscribe

func (srv *Server) Subscribe(topic string, handler broker.Handler, opts ...func(o *broker.SubscribeOptions)) error

Subscribe 消息异步订阅

func (*Server) Unmarshal

func (srv *Server) Unmarshal(v interface{}) error

Unmarshal 序列化 configuration 中的自定义配置项

func (*Server) Use

func (srv *Server) Use(middleware ...gin.HandlerFunc)

Use .

Directories

Path Synopsis
jwt

Jump to

Keyboard shortcuts

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