servers

package
v0.5.19 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 23 Imported by: 5

Documentation

Overview

gen for home toolset

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllProvider

func GetAllProvider() []interface{}

func GetServer

func GetServer(leaders ...interface{}) constraint.KernelServer

GetServer 提供统一命名规范的独立服务

Types

type Broadcast

type Broadcast struct {
	Connect *services.Redis

	Run bool
	// contains filtered or unexported fields
}

func (*Broadcast) Close added in v0.0.3

func (b *Broadcast) Close()

func (*Broadcast) Publish

func (b *Broadcast) Publish(topic string, m Msg)

func (*Broadcast) Subscribe

func (b *Broadcast) Subscribe(topic string)

Subscribe 订阅主题

type Cron added in v0.5.0

type Cron func(job func())

type Crontab

type Crontab struct {
	Cron *cron.Cron
	// contains filtered or unexported fields
}

Crontab @Bean

func NewCrontab

func NewCrontab() *Crontab

func (*Crontab) AddFunc

func (crontab *Crontab) AddFunc(spec string, cmd func()) (cron.EntryID, error)

func (*Crontab) AddJob

func (crontab *Crontab) AddJob(spec string, cmd cron.Job) (cron.EntryID, error)

func (*Crontab) AddMiddleware added in v0.5.0

func (crontab *Crontab) AddMiddleware(task Cron)

func (*Crontab) Exit

func (crontab *Crontab) Exit()

func (*Crontab) Init

func (crontab *Crontab) Init()

func (*Crontab) Run

func (crontab *Crontab) Run()

type DelayQueue added in v0.3.0

type DelayQueue interface {
	Push(DelayTask) string
	Del(string) bool
	Run()
}

type DelayQueueForMysql added in v0.3.0

type DelayQueueForMysql struct {
	RunAfterFuncLimit int64
	// contains filtered or unexported fields
}

DelayQueueForMysql @Bean("delay_queue")

func NewDelayQueueForMysql added in v0.3.0

func NewDelayQueueForMysql() *DelayQueueForMysql

func (*DelayQueueForMysql) Del added in v0.3.0

func (d *DelayQueueForMysql) Del(id string) bool

func (*DelayQueueForMysql) Init added in v0.3.0

func (d *DelayQueueForMysql) Init()

func (*DelayQueueForMysql) Loop added in v0.3.0

func (d *DelayQueueForMysql) Loop()

Loop 监控执行 一分钟内的任务,如果系统空闲,直接维护在内存,同时设置数据库in_cache=1 超过一分钟的任务,放到数据库,每分钟加载到内存

func (*DelayQueueForMysql) Push added in v0.3.0

func (d *DelayQueueForMysql) Push(task DelayTask) string

func (*DelayQueueForMysql) Run added in v0.3.0

func (d *DelayQueueForMysql) Run()

func (*DelayQueueForMysql) RunAfterFunc added in v0.4.22

func (d *DelayQueueForMysql) RunAfterFunc(delayMsg *OrmDelayQueue)

func (*DelayQueueForMysql) RunDelayJob added in v0.4.22

func (d *DelayQueueForMysql) RunDelayJob(delayMsg *OrmDelayQueue) bool

type DelayTask added in v0.3.0

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

DelayTask 延时队列包装

func (*DelayTask) Push added in v0.3.0

func (d *DelayTask) Push(message interface{})

type Election

type Election struct {
	// 队列配置文件的所有配置
	*services.Config `inject:"config, election"`
	// 连接
	Connect *services.Redis
	// contains filtered or unexported fields
}

Election @Bean("election")

func NewElection

func NewElection() *Election

func (*Election) AppendRun

func (k *Election) AppendRun(fun func())

func (*Election) Exit

func (k *Election) Exit()

func (*Election) Init

func (k *Election) Init()

func (*Election) Run

func (k *Election) Run()

type Http

type Http struct {
	*providers.RouteProvider `inject:""`
	*services.HttpServer     `inject:""`
	*services.Config         `inject:"config, app.servers.http"`

	*gin.Engine
	Middleware      []gin.HandlerFunc
	MiddlewareGroup map[string][]gin.HandlerFunc

	Port string
	// contains filtered or unexported fields
}

Http 提供者 @Bean("http")

func NewHttp

func NewHttp() *Http

func (*Http) Boot

func (http *Http) Boot()

func (*Http) Exit

func (http *Http) Exit()

func (*Http) Init

func (http *Http) Init()

func (*Http) Run

func (http *Http) Run()

type Msg

type Msg struct {
	Route string `json:"route"`
	Data  string `json:"event"`
}

type OrmDelayQueue added in v0.3.0

type OrmDelayQueue struct {
	Id    string        `gorm:"column:id;type:varchar(64);primaryKey"`                         //
	Fail  uint64        `gorm:"column:fail;type:bigint(20) unsigned;default:0;comment:'失败次数'"` // 失败次数
	Route string        `gorm:"column:route;type:varchar(254);comment:'路由'"`                   // 路由
	Job   database.JSON `gorm:"column:job;type:json;comment:'任务信息'"`                           // 任务信息
	RunAt database.Time ``                                                                     // 执行时间点
	/* 130-byte string literal not displayed */
	CreatedAt database.Time `gorm:"column:created_at;type:timestamp;default:2022-08-25 00:00:00;comment:'创建时间'"` // 创建时间
	InCache   uint32        `gorm:"column:in_cache;type:tinyint(4) unsigned;default:0;comment:'是否加入缓存'"`         // 是否加入缓存
}

OrmDelayQueue @Bean

func NewOrmDelayQueue added in v0.3.0

func NewOrmDelayQueue() *OrmDelayQueue

func (*OrmDelayQueue) TableName added in v0.3.0

func (receiver *OrmDelayQueue) TableName() string

type Queue

type Queue struct {

	// 连接
	Connect *services.Redis `inject:"database, @config(queue.connection)"`
	// contains filtered or unexported fields
}

Queue @Bean("queue")

func NewQueue

func NewQueue() *Queue

func (*Queue) AddJob

func (q *Queue) AddJob(route string, handle constraint.Job)

func (*Queue) AddMiddleware added in v0.5.0

func (q *Queue) AddMiddleware(task Task)

func (*Queue) CloseBroadcast added in v0.0.3

func (q *Queue) CloseBroadcast()

func (*Queue) Delay added in v0.1.9

func (q *Queue) Delay(t time.Duration) *DelayTask

Delay 延后投递执行

func (*Queue) Exit

func (q *Queue) Exit()

func (*Queue) HasBroadcast

func (q *Queue) HasBroadcast() bool

func (*Queue) Init

func (q *Queue) Init()

func (*Queue) Listen

func (q *Queue) Listen(jobs []interface{})

func (*Queue) Publish

func (q *Queue) Publish(message interface{}, topics ...string)

Publish 对message广播

func (*Queue) Push

func (q *Queue) Push(message interface{})

Push 投递队列

func (*Queue) Run

func (q *Queue) Run()

func (*Queue) StartBroadcast

func (q *Queue) StartBroadcast() *Broadcast

func (*Queue) StartDelayQueue added in v0.1.9

func (q *Queue) StartDelayQueue()

StartDelayQueue 开启延时队列

type Task added in v0.5.0

type Task func(job constraint.Job, next func(constraint.Job))

type Websocket

type Websocket struct {
}

Websocket @Bean

func NewWebsocket

func NewWebsocket() *Websocket

func (*Websocket) Exit

func (w *Websocket) Exit()

func (*Websocket) Init

func (w *Websocket) Init()

func (*Websocket) Run

func (w *Websocket) Run()

Jump to

Keyboard shortcuts

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