1 Star 0 Fork 2

何吕 / volantmq

forked from JUMEI_ARCH / volantmq 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
provider.go 1.60 KB
一键复制 编辑 原始数据 按行查看 历史
Artur Troian 提交于 2017-08-05 21:46 . Enable systree
package mem
import "github.com/troian/surgemq/persistence/types"
type dbStatus struct {
done chan struct{}
}
type impl struct {
status dbStatus
r retained
s sessions
subs subscriptions
sys system
}
// New allocate new persistence provider of boltDB type
func New(config *persistenceTypes.MemConfig) (p persistenceTypes.Provider, err error) {
pl := &impl{}
pl.status.done = make(chan struct{})
pl.r = retained{
status: &pl.status,
}
pl.s = sessions{
status: &pl.status,
sessions: make(map[string]*persistenceTypes.SessionState),
}
pl.subs = subscriptions{
status: &pl.status,
subs: make(map[string][]byte),
}
pl.sys = system{
status: &pl.status,
}
return pl, nil
}
func (p *impl) System() (persistenceTypes.System, error) {
select {
case <-p.status.done:
return nil, persistenceTypes.ErrNotOpen
default:
}
return &p.sys, nil
}
// Sessions
func (p *impl) Sessions() (persistenceTypes.Sessions, error) {
select {
case <-p.status.done:
return nil, persistenceTypes.ErrNotOpen
default:
}
return &p.s, nil
}
// Retained
func (p *impl) Retained() (persistenceTypes.Retained, error) {
select {
case <-p.status.done:
return nil, persistenceTypes.ErrNotOpen
default:
}
return &p.r, nil
}
// Subscriptions
func (p *impl) Subscriptions() (persistenceTypes.Subscriptions, error) {
select {
case <-p.status.done:
return nil, persistenceTypes.ErrNotOpen
default:
}
return &p.subs, nil
}
// Shutdown provider
func (p *impl) Shutdown() error {
select {
case <-p.status.done:
return persistenceTypes.ErrNotOpen
default:
close(p.status.done)
}
return nil
}
Go
1
https://gitee.com/kaifazhe/volantmq.git
git@gitee.com:kaifazhe/volantmq.git
kaifazhe
volantmq
volantmq
v0.0.1-beta

搜索帮助