4 Star 5 Fork 4

Plato/Service-Box-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
source.go 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
CloudGuan 提交于 2023-10-13 19:30 . feature: 配置系统支持热更
package source
import (
"crypto/md5"
"fmt"
"time"
)
type (
// ChangeSet represents a set of changes from a source
ChangeSet struct {
Data []byte // binary data
Checksum string // md5 sum
Format string // type of the data
Source string // name of the data source
Timestamp time.Time // time stamp
}
// Watcher is the data source change monitor
Watcher interface {
Next() (*ChangeSet, error) // Method returns the changed data set when the data source changes
Stop() error // Method stops the data source change monitor
}
// Source is configure the data source from which the data loader retrieves the raw binary data.
Source interface {
Read() (*ChangeSet, error) // read from source, to change set
Watch() (Watcher, error) // watch the source change
String() string // return the name of the data source
}
)
// Sum returns the md5 checksum of the ChangeSet data
func (c *ChangeSet) Sum() string {
h := md5.New()
h.Write(c.Data)
return fmt.Sprintf("%x", h.Sum(nil))
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/dennis-kk/service-box-go.git
git@gitee.com:dennis-kk/service-box-go.git
dennis-kk
service-box-go
Service-Box-go
v0.5.15

搜索帮助

Cb406eda 1850385 E526c682 1850385