servers

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: MIT Imports: 21 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 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) 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 {
	// 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 TODO 待优化,如果启动了广播,可以内存维护多个节点的最近任务,可以去掉定时查询

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()

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:"primaryKey;autoIncrement;column:id;type:varchar(64);not null" json:"id"`
	Fail      int           `gorm:"column:fail;type:int" json:"fail"`
	Route     string        `gorm:"column:route;type:varchar(254)" json:"route"`
	Job       database.JSON `gorm:"column:job;type:json" json:"job"`
	RunAt     database.Time `gorm:"column:run_at;type:timestamp;index;not null" json:"run_at"`
	CreatedAt database.Time `gorm:"column:created_at;type:timestamp;not null;default:'2022-08-25 00:00:00'" json:"created_at"`
}

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) 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()

func (*Queue) StartDelayQueue added in v0.1.9

func (q *Queue) StartDelayQueue()

StartDelayQueue 开启延时队列

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