-
Notifications
You must be signed in to change notification settings - Fork 0
/
beehive.go
64 lines (50 loc) · 1.08 KB
/
beehive.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package beehive
import (
"log"
"os"
"time"
"github.com/pkg/errors"
)
const (
OPEND = iota
CLOSED
)
var (
defaultLogger = Logger(log.New(os.Stderr, "", log.LstdFlags))
defaultSize = 1024
defaultInstance = NewBeehive(defaultSize)
defaultCleanIntervalTime = time.Minute
defaultDumpFile = "./beehive.json"
ErrBeehiveClosed = errors.New("this beehive has been closed")
ErrTopicUnRegisted = errors.New("this topic unregisted")
)
type Logger interface {
Printf(format string, args ...interface{})
}
func Publish(topic string, data interface{}) {
defaultInstance.Publish(topic, data)
}
func Release() {
defaultInstance.Release()
}
func IsClosed() bool {
return defaultInstance.IsClosed()
}
func Subscribe(topic string, listeners ...Handle) {
defaultInstance.Subscribe(topic, listeners...)
}
func Cap() int {
return defaultInstance.Cap()
}
func Running() int {
return defaultInstance.Running()
}
func Reboot() {
defaultInstance.Reboot()
}
func Free() {
defaultInstance.Free()
}
func Load() {
defaultInstance.Load()
}