Apply .gitignore rules
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
package notify_util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"goutil/syncUtil"
|
||||
)
|
||||
|
||||
var (
|
||||
// key:初始化成功的标志名称 val:占位符
|
||||
registerNC = make(map[string]*notifyCenter)
|
||||
mutex = syncUtil.NewRWLocker()
|
||||
)
|
||||
|
||||
// getItemOrAdd
|
||||
// @description: 获取注册的通知对象
|
||||
// parameter:
|
||||
// @chanGroup:
|
||||
// return:
|
||||
// @*notifyCenter:
|
||||
func getItemOrAdd(chanGroup string) *notifyCenter {
|
||||
if isOk, prevStack, currStack := mutex.Lock(deathLockTime); isOk == false {
|
||||
//记日志
|
||||
errMsg := fmt.Sprintf("Lock timeout! \n上一个堆栈:\n%s \n当前堆栈:\n%s", prevStack, currStack)
|
||||
panic(errMsg)
|
||||
}
|
||||
defer mutex.Unlock()
|
||||
|
||||
nc, exists := registerNC[chanGroup]
|
||||
if exists {
|
||||
return nc
|
||||
}
|
||||
|
||||
nc = newNotifyCenter()
|
||||
registerNC[chanGroup] = nc
|
||||
|
||||
return nc
|
||||
}
|
||||
|
||||
// Register
|
||||
// @description: 注册需要被通知的对象
|
||||
// parameter:
|
||||
// @chanGroup:通知的分组标识
|
||||
// @chanName:唯一标识
|
||||
// @cf:回调方法
|
||||
// return:
|
||||
func Register(chanGroup string, chanName string, cf func()) {
|
||||
nc := getItemOrAdd(chanGroup)
|
||||
nc.register(chanName, cf)
|
||||
}
|
||||
|
||||
// Unregister
|
||||
// @description: 取消启动成功通知注册
|
||||
// parameter:
|
||||
// @chanGroup:分组标识
|
||||
// @name:唯一标识
|
||||
// return:
|
||||
func Unregister(chanGroup string, name string) {
|
||||
nc := getItemOrAdd(chanGroup)
|
||||
nc.unregister(name)
|
||||
}
|
||||
|
||||
// Notify
|
||||
// @description: 通知分组所有已注册的对象
|
||||
// parameter:
|
||||
// @chanGroup:分组标识
|
||||
// return:
|
||||
func Notify(chanGroup string) {
|
||||
nc := getItemOrAdd(chanGroup)
|
||||
nc.notify()
|
||||
}
|
||||
|
||||
// Notify2
|
||||
// @description: 通知所有已注册的对象,该方法会在捕获第一个err的时候停止后续的通知。多用于系统启动的判定
|
||||
// parameter:
|
||||
// @chanGroup:分组标识
|
||||
// return:
|
||||
// @err:
|
||||
func Notify2(chanGroup string) (err error) {
|
||||
nc := getItemOrAdd(chanGroup)
|
||||
err = nc.notify2()
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
### 窗口周期计数器
|
||||
窗口周期计数类,用于记录一个窗口周期数量,并且触发某个操作的场景。
|
||||
在下一个窗口周期会自动重置次数
|
||||
|
||||
#### =======================>使用方法说明<=========================
|
||||
|
||||
1.引入包
|
||||
2.构造对象并次有
|
||||
3.调用对象的增加次数方法
|
||||
|
||||
```go
|
||||
package demo
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"goutil/counter_util"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 构造名字叫test的,窗口间隔为1s,计数达到2就会触发警告的窗口计数器
|
||||
c := counter_util.NewCounterUtil("test", 2, checkId, func(tag string, num int, ti time.Time) {
|
||||
//自定义触发动作
|
||||
})
|
||||
|
||||
c.AddNum(1)
|
||||
c.AddNum(10)
|
||||
}
|
||||
|
||||
// 窗口周期设定为1s
|
||||
func checkId(t1, t2 time.Time) bool {
|
||||
return t1.Second() == t2.Second()
|
||||
}
|
||||
|
||||
```
|
||||
@@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"common/connection"
|
||||
"sync"
|
||||
|
||||
_ "common/resultStatus"
|
||||
"common/webServer"
|
||||
_ "logincenter/internal/user"
|
||||
)
|
||||
|
||||
var (
|
||||
wg sync.WaitGroup
|
||||
)
|
||||
|
||||
func init() {
|
||||
// 设置WaitGroup需要等待的数量,只要有一个服务器出现错误都停止服务器
|
||||
wg.Add(1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
//加载配置
|
||||
loadConfig()
|
||||
|
||||
// 启动webserver
|
||||
go webServer.Start(&wg)
|
||||
|
||||
// 阻塞等待,以免main线程退出
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
// loadConfig 用于加载配置信息。
|
||||
// 该函数会读取配置文件或环境变量中的设置,并根据这些设置初始化程序所需的配置。
|
||||
// 目前函数的实现为空,需要根据实际的配置加载逻辑进行填充。
|
||||
func loadConfig() {
|
||||
|
||||
//构建数据库
|
||||
connection.BuildDB()
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
module logincenter
|
||||
|
||||
go 1.22.10
|
||||
|
||||
replace (
|
||||
common => ../common
|
||||
framework => ../../framework
|
||||
goutil => ../../goutil
|
||||
)
|
||||
|
||||
require common v0.0.0-00010101000000-000000000000
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
framework v0.0.0-20230425160006-b2d0b0a0b0b0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||
github.com/gomodule/redigo v1.8.9 // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/jinzhu/gorm v1.9.12 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
|
||||
gorm.io/driver/mysql v1.5.7 // indirect
|
||||
gorm.io/gorm v1.25.12 // indirect
|
||||
goutil v0.0.0-20230425160006-b2d0b0a0b0b0 // indirect
|
||||
)
|
||||
@@ -0,0 +1,6 @@
|
||||
package verifyMgr
|
||||
|
||||
/*
|
||||
此包用于对指定url进行访问验证,以便于在程序启动时可以提前知道目标地址的可访问性,
|
||||
而不用等到实际需要时再验证;从而造成既定的影响。
|
||||
*/
|
||||
Reference in New Issue
Block a user