forked from p93542168/wheat-cache
Compare commits
6 Commits
master
...
feat-middl
Author | SHA1 | Date |
---|---|---|
Sodesnei | 1963843125 | |
Sodesnei | a606fbb08a | |
Sodesnei | 6a1d8a3621 | |
Sodesnei | c21261ba94 | |
Sodesnei | 8685f5f24a | |
Sodesnei | ec78e6bfd5 |
|
@ -6,17 +6,17 @@ type SingleWorkFunc func() interface{}
|
|||
|
||||
const (
|
||||
OptionEventName = "operateEvent"
|
||||
CleanEventName = "clearEvent"
|
||||
CleanEventName = "clearEvent"
|
||||
WorkFuncEventKey = "workFunc"
|
||||
)
|
||||
|
||||
var (
|
||||
lruCacheOnce sync.Once
|
||||
lruCache *singleCache
|
||||
lruCache *singleCache
|
||||
)
|
||||
|
||||
const (
|
||||
lruMaxSize = 1*1024*1024*1024*8
|
||||
lruClearSize = 0.5*1024*1024*1024*8
|
||||
lruMaxSize = 1 * 1024 * 1024 * 1024 * 8
|
||||
lruClearSize = 0.5 * 1024 * 1024 * 1024 * 8
|
||||
lruEventDriver = 2000
|
||||
)
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
package middle
|
||||
|
||||
import getMiddlewareMap "gitee.com/timedb/wheatCache/plugins/config"
|
||||
import (
|
||||
"sync"
|
||||
|
||||
func Init() {
|
||||
getMiddlewareMap.GetMiddlewareMap()
|
||||
"gitee.com/timedb/wheatCache/plugins"
|
||||
getMiddlewareMap "gitee.com/timedb/wheatCache/plugins/config"
|
||||
)
|
||||
|
||||
func Init() map[string]plugins.MiddleToolsInterface {
|
||||
return getMiddlewareMap.GetMiddlewareMap()
|
||||
}
|
||||
|
||||
var (
|
||||
oneMiddle sync.Once
|
||||
MiddleWareDriver *MiddleWare
|
||||
)
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package middle
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitee.com/timedb/wheatCache/pkg/event"
|
||||
)
|
||||
|
||||
type MiddleWare struct {
|
||||
eventDriver event.DriverInterface
|
||||
eventConsumer event.ConsumerInterface
|
||||
}
|
||||
|
||||
func NewMiddleWare() *MiddleWare {
|
||||
oneMiddle.Do(func() {
|
||||
driver := event.NewDriver(1000)
|
||||
MiddleWareDriver = &MiddleWare{
|
||||
eventDriver: driver,
|
||||
eventConsumer: event.NewConsumer(driver),
|
||||
}
|
||||
})
|
||||
return MiddleWareDriver
|
||||
}
|
||||
|
||||
func (m *MiddleWare) GetEventDriver() event.DriverInterface {
|
||||
return m.eventDriver
|
||||
}
|
||||
|
||||
func (m *MiddleWare) work(ctx context.Context) {
|
||||
getMiddlewareMap := Init()
|
||||
fmt.Println(getMiddlewareMap)
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package middle
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"gitee.com/timedb/wheatCache/pkg/event"
|
||||
)
|
||||
|
||||
func Test_middleware_driver(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
type Library struct {
|
||||
driver MiddleWare
|
||||
}
|
||||
|
||||
library := &Library{
|
||||
driver: *NewMiddleWare(),
|
||||
}
|
||||
|
||||
library.driver.work(ctx)
|
||||
|
||||
type A struct {
|
||||
produce event.ProduceInterface
|
||||
}
|
||||
|
||||
a := &A{
|
||||
produce: event.NewProduce(library.driver.eventDriver),
|
||||
}
|
||||
|
||||
type B struct {
|
||||
cumsumer event.ConsumerInterface
|
||||
}
|
||||
|
||||
b := &B{
|
||||
cumsumer: event.NewConsumer(library.driver.eventDriver),
|
||||
}
|
||||
|
||||
book := event.NewEvent("book")
|
||||
book.SetMsg("title", "goland")
|
||||
book.SetValue("page", 100)
|
||||
|
||||
go func() {
|
||||
a.produce.Call(ctx, book)
|
||||
}()
|
||||
|
||||
b_book := b.cumsumer.Receive(ctx)
|
||||
fmt.Println(b_book.GetMsg("title"))
|
||||
}
|
|
@ -62,7 +62,6 @@ def set_structure_const_template(conf: dict):
|
|||
val_set = []
|
||||
for k, v in conf.items():
|
||||
key_map.append(KeyMap(key=k, val=v))
|
||||
|
||||
for val in v:
|
||||
val_set.append(val.upper())
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ def out_proto():
|
|||
for f in files:
|
||||
commend = comm.format(protoPath, root, sysPath, f).strip()
|
||||
err = os.system(commend)
|
||||
|
||||
|
||||
if err:
|
||||
print(f, "-> out put err")
|
||||
else:
|
||||
|
@ -23,3 +23,4 @@ def out_proto():
|
|||
|
||||
if __name__ == '__main__':
|
||||
out_proto()
|
||||
|
||||
|
|
Loading…
Reference in New Issue