Compare commits

...

6 Commits

Author SHA1 Message Date
Sodesnei 1963843125 fix(middle_driver): delete middleware 2021-10-04 21:42:34 +08:00
Sodesnei a606fbb08a fix(middle-driver): edit middledriver var 2021-10-04 21:40:24 +08:00
Sodesnei 6a1d8a3621 feat(middle-driver): get middleware map 2021-10-04 21:34:07 +08:00
Sodesnei c21261ba94 feat(middle): driver get middleware map 2021-10-04 21:31:15 +08:00
Sodesnei 8685f5f24a feat(middleware): add middleware 2021-10-04 21:31:15 +08:00
Sodesnei ec78e6bfd5 test(middleware_driver): add middleware driver test 2021-10-04 21:30:27 +08:00
6 changed files with 103 additions and 9 deletions

View File

@ -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
)

View File

@ -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
)

View File

@ -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)
}

View File

@ -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"))
}

View File

@ -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())

View File

@ -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()