Skip to content

Commit

Permalink
type Newer = func(args interface{}) (dot Dot, err error)
Browse files Browse the repository at this point in the history
to: type Newer = func(args []byte) (dot Dot, err error)
  • Loading branch information
peacess committed Nov 21, 2019
1 parent 94e6458 commit 2ba9d58
Show file tree
Hide file tree
Showing 27 changed files with 91 additions and 135 deletions.
33 changes: 8 additions & 25 deletions build-all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,21 @@ set batPath=%cd%

cd %batPath%/dots
set dotPath=%cd%
go mod tidy
cd %dotPath%/certificate & go build
cd %dotPath%/gindot & go mod tidy & go build
cd %dotPath%/grpc & go mod tidy
cd %dotPath%/grpc/conns & go build
cd %dotPath%/grpc/lb & go build
cd %dotPath%/grpc/gserver & go build
cd %dotPath%/line & go build
cd %dotPath%/sconfig & go build
cd %dotPath%/slog & go build

cd %dotPath% & go build ./...
cd %dotPath%/db & go build ./...
cd %dotPath%/db/tools & go build ./...
cd %dotPath%/grpc & go build ./...

cd %batPath%/sample
set samplePath=%cd%
go build
cd %samplePath%/certificate & go build
cd %samplePath%/event & go build
cd %samplePath%/gindot & go mod tidy & go build
go build ./...
cd %samplePath%/db/pgs & go build ./...
setlocal
call %samplePath%/grpc/proto/build_go.bat
endlocal
cd %samplePath%/grpc & go mod tidy
cd %samplePath%/grpc/conns & go build
cd %samplePath%/grpc/nobl/client & go build
cd %samplePath%/grpc/nobl/server & go build
cd %samplePath%/grpc/nobl/server2 & go build
cd %samplePath%/grpc & go build ./...
cd %samplePath%/grpc/nobl & go build ./...
cd %samplePath%/grpc/http/server & go build

cd %samplePath% & go clean ./...
cd %samplePath%/gindot & go clean ./...
cd %samplePath%/grpc & go clean ./...
cd %samplePath%/grpc/tls & go clean ./...

cd %batPath%

23 changes: 23 additions & 0 deletions build-dot.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

@echo on


cd %~dp0
%~d0
set batPath=%cd%

cd %batPath%/dots
set dotPath=%cd%

cd %batPath%/dot & go build

cd %dotPath%/line & go build
cd %dotPath%/sconfig & go build
cd %dotPath%/slog & go build

cd %batPath%/sample
set samplePath=%cd%
go build

cd %batPath%

4 changes: 2 additions & 2 deletions dot/dot.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (m *Metadata) Merge(m2 *Metadata) {
}

//NewDot new a dot
func (m *Metadata) NewDot(args interface{}) (dot Dot, err error) {
func (m *Metadata) NewDot(args []byte) (dot Dot, err error) {
dot = nil
err = nil
if m.NewDoter != nil {
Expand All @@ -144,7 +144,7 @@ func (m *Metadata) NewDot(args interface{}) (dot Dot, err error) {
}

//Newer instace for new dot
type Newer = func(args interface{}) (dot Dot, err error)
type Newer = func(args []byte) (dot Dot, err error)

//Dot componet
type Dot interface{}
Expand Down
4 changes: 2 additions & 2 deletions dots/certificate/ecdsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
type Ecdsa struct {
}

func newEcdsa(conf interface{}) (dot.Dot, error) {
func newEcdsa(conf []byte) (dot.Dot, error) {
var err error = nil
_ = conf
d := &Ecdsa{}
Expand All @@ -37,7 +37,7 @@ func newEcdsa(conf interface{}) (dot.Dot, error) {

func TypeLiveEcdsa() *dot.TypeLives {
return &dot.TypeLives{
Meta: dot.Metadata{TypeId: EcdsaTypeId, NewDoter: func(conf interface{}) (dot dot.Dot, err error) {
Meta: dot.Metadata{TypeId: EcdsaTypeId, NewDoter: func(conf []byte) (dot dot.Dot, err error) {
return newEcdsa(conf)
}},
}
Expand Down
4 changes: 3 additions & 1 deletion dots/db/gorms/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ require (
github.com/jinzhu/gorm v1.9.11
github.com/lib/pq v1.2.0 // indirect
github.com/pkg/errors v0.8.1
github.com/scryinfo/dot v0.1.3-0.20191026033258-058b492d7717
github.com/scryinfo/dot v0.1.3
go.uber.org/atomic v1.5.1 // indirect
go.uber.org/multierr v1.4.0 // indirect
go.uber.org/zap v1.13.0
golang.org/x/tools v0.0.0-20191120221951-8fd459516a27 // indirect
google.golang.org/appengine v1.6.5 // indirect
)

replace github.com/scryinfo/dot v0.1.3 => ../../../
13 changes: 3 additions & 10 deletions dots/db/gorms/gorms.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,22 @@ func (c *Gorms) Create(l dot.Line) (err error) {
return err
}

func newGorms(conf interface{}) (d dot.Dot, err error) {
var bs []byte
if bt, ok := conf.([]byte); ok {
bs = bt
} else {
return nil, dot.SError.Parameter
}
func newGorms(conf []byte) (d dot.Dot, err error) {
dconf := &config{}
err = dot.UnMarshalConfig(bs, dconf)
err = dot.UnMarshalConfig(conf, dconf)
if err != nil {
return nil, err
}

d = &Gorms{conf: *dconf}

return d, err
}

//TypeLives
func TypeLives() []*dot.TypeLives {
lives := []*dot.TypeLives{
{
Meta: dot.Metadata{TypeId: TypeId, NewDoter: func(conf interface{}) (dot dot.Dot, err error) {
Meta: dot.Metadata{TypeId: TypeId, NewDoter: func(conf []byte) (dot dot.Dot, err error) {
return newGorms(conf)
}},
},
Expand Down
13 changes: 3 additions & 10 deletions dots/db/pgs/conn_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,9 @@ func (c *ConnWrapper) TestConn() bool {
}

//construct dot
func newConnWrapper(conf interface{}) (dot.Dot, error) {
var err error
var bs []byte
if bt, ok := conf.([]byte); ok {
bs = bt
} else {
return nil, dot.SError.Parameter
}
func newConnWrapper(conf []byte) (dot.Dot, error) {
dconf := &config{}
err = dot.UnMarshalConfig(bs, dconf)
err := dot.UnMarshalConfig(conf, dconf)
if err != nil {
return nil, err
}
Expand All @@ -73,7 +66,7 @@ func newConnWrapper(conf interface{}) (dot.Dot, error) {
//ConnWrapperTypeLives make all type lives
func ConnWrapperTypeLives() []*dot.TypeLives {
tl := &dot.TypeLives{
Meta: dot.Metadata{TypeId: ConnWrapperTypeId, NewDoter: func(conf interface{}) (dot.Dot, error) {
Meta: dot.Metadata{TypeId: ConnWrapperTypeId, NewDoter: func(conf []byte) (dot.Dot, error) {
return newConnWrapper(conf)
}},
}
Expand Down
2 changes: 1 addition & 1 deletion dots/db/pgs/dao_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (c *DaoBase) WithNoTx(tast func(conn *pg.Conn) error) error {
//DaoBaseTypeLives make all type lives
func DaoBaseTypeLives() []*dot.TypeLives {
tl := &dot.TypeLives{
Meta: dot.Metadata{TypeId: DaoBaseTypeId, NewDoter: func(conf interface{}) (dot.Dot, error) {
Meta: dot.Metadata{TypeId: DaoBaseTypeId, NewDoter: func(conf []byte) (dot.Dot, error) {
return &DaoBase{}, nil
}},
Lives: []dot.Live{
Expand Down
4 changes: 3 additions & 1 deletion dots/db/pgs/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/onsi/ginkgo v1.10.1 // indirect
github.com/onsi/gomega v1.7.0 // indirect
github.com/scryinfo/dot v0.1.3-0.20191026032307-4fe8cc8e04c9
github.com/scryinfo/dot v0.1.3
golang.org/x/net v0.0.0-20190420063019-afa5a82059c6 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
mellium.im/sasl v0.2.1 // indirect
)

replace github.com/scryinfo/dot v0.1.3 => ../../../
13 changes: 3 additions & 10 deletions dots/gindot/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,9 @@ func DefaultGinEngine() *gin.Engine {
}

//construct dot
func newGinDot(conf interface{}) (dot.Dot, error) {
var err error
var bs []byte
if bt, ok := conf.([]byte); ok {
bs = bt
} else {
return nil, dot.SError.Parameter
}
func newGinDot(conf []byte) (dot.Dot, error) {
dconf := &configEngine{}
err = dot.UnMarshalConfig(bs, dconf)
err := dot.UnMarshalConfig(conf, dconf)
if err != nil {
return nil, err
}
Expand All @@ -82,7 +75,7 @@ func newGinDot(conf interface{}) (dot.Dot, error) {
//TypeLiveGinDot generate data for structural dot
func TypeLiveGinDot() *dot.TypeLives {
return &dot.TypeLives{
Meta: dot.Metadata{TypeId: EngineTypeId, NewDoter: func(conf interface{}) (dot dot.Dot, err error) {
Meta: dot.Metadata{TypeId: EngineTypeId, NewDoter: func(conf []byte) (dot dot.Dot, err error) {
return newGinDot(conf)
}},
}
Expand Down
4 changes: 2 additions & 2 deletions dots/gindot/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ go 1.12
require (
github.com/gin-gonic/gin v1.4.0
github.com/mattn/go-isatty v0.0.8 // indirect
github.com/scryinfo/dot v0.1.3-0.20191026032307-4fe8cc8e04c9
github.com/scryinfo/dot v0.1.3
github.com/scryinfo/scryg v0.1.3-0.20190608053141-a292b801bfd6
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 // indirect
golang.org/x/sys v0.0.0-20190529164535-6a60838ec259 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
)

replace github.com/scryinfo/dot v0.0.0 => ../../
replace github.com/scryinfo/dot v0.1.3 => ../../
13 changes: 3 additions & 10 deletions dots/gindot/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,9 @@ type Router struct {
}

//construct dot
func newRouter(conf interface{}) (*Router, error) {
var err error
var bs []byte
if bt, ok := conf.([]byte); ok {
bs = bt
} else {
return nil, dot.SError.Parameter
}
func newRouter(conf []byte) (*Router, error) {
dconf := &configRouter{}
err = dot.UnMarshalConfig(bs, dconf)
err := dot.UnMarshalConfig(conf, dconf)
if err != nil {
return nil, err
}
Expand All @@ -50,7 +43,7 @@ func newRouter(conf interface{}) (*Router, error) {
//TypeLiveRouter generate data for structural dot, include gindot.Engine
func TypeLiveRouter() []*dot.TypeLives {
return []*dot.TypeLives{&dot.TypeLives{
Meta: dot.Metadata{TypeId: RouterTypeId, NewDoter: func(conf interface{}) (dot.Dot, error) {
Meta: dot.Metadata{TypeId: RouterTypeId, NewDoter: func(conf []byte) (dot.Dot, error) {
return newRouter(conf)
}},
},
Expand Down
13 changes: 3 additions & 10 deletions dots/grpc/conns/conn_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,9 @@ type configName struct {
Name string `json:"name"`
}

func newConnName(conf interface{}) (dot.Dot, error) {
var err error = nil
var bs []byte = nil
if bt, ok := conf.([]byte); ok {
bs = bt
} else {
return nil, dot.SError.Parameter
}
func newConnName(conf []byte) (dot.Dot, error) {
dconf := &configName{}
err = dot.UnMarshalConfig(bs, dconf)
err := dot.UnMarshalConfig(conf, dconf)
if err != nil {
return nil, err
}
Expand All @@ -45,7 +38,7 @@ func newConnName(conf interface{}) (dot.Dot, error) {

func ConnNameTypeLives() []*dot.TypeLives {
return []*dot.TypeLives{{
Meta: dot.Metadata{TypeId: ConnNameTypeId, NewDoter: func(conf interface{}) (dot dot.Dot, err error) {
Meta: dot.Metadata{TypeId: ConnNameTypeId, NewDoter: func(conf []byte) (dot dot.Dot, err error) {
return newConnName(conf)
}},
},
Expand Down
13 changes: 3 additions & 10 deletions dots/grpc/conns/conns.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,9 @@ type connsImp struct {
}

//Construction component
func newConns(conf interface{}) (dot.Dot, error) {
var err error = nil
var bs []byte = nil
if bt, ok := conf.([]byte); ok {
bs = bt
} else {
return nil, dot.SError.Parameter
}
func newConns(conf []byte) (dot.Dot, error) {
dconf := &connsConfig{}
err = dot.UnMarshalConfig(bs, dconf)
err := dot.UnMarshalConfig(conf, dconf)
if err != nil {
return nil, err
}
Expand All @@ -85,7 +78,7 @@ func newConns(conf interface{}) (dot.Dot, error) {
//Data structure needed when generating newer component
func ConnsTypeLives() *dot.TypeLives {
return &dot.TypeLives{
Meta: dot.Metadata{TypeId: ConnsTypeId, NewDoter: func(conf interface{}) (dot dot.Dot, err error) {
Meta: dot.Metadata{TypeId: ConnsTypeId, NewDoter: func(conf []byte) (dot dot.Dot, err error) {
return newConns(conf)
}},
}
Expand Down
6 changes: 3 additions & 3 deletions dots/grpc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223 // indirect
github.com/pkg/errors v0.8.1
github.com/rs/cors v1.6.0 // indirect
github.com/scryinfo/dot v0.1.3-0.20190907084536-c60f8a67fccd
github.com/scryinfo/dot v0.1.3
github.com/scryinfo/dot/dots/gindot v0.0.0-20191026032307-4fe8cc8e04c9
github.com/ugorji/go v1.1.7 // indirect
go.uber.org/multierr v1.2.0 // indirect
Expand All @@ -26,6 +26,6 @@ require (
)

replace (
github.com/scryinfo/dot v0.1.3-0.20190907084536-c60f8a67fccd => ../../
github.com/scryinfo/dot/dots/gindot v0.0.0-20190622091252-bab0929bd7e7 => ../gindot
github.com/scryinfo/dot v0.1.3 => ../../
github.com/scryinfo/dot/dots/gindot v0.0.0-20191026032307-4fe8cc8e04c9 => ../gindot
)
2 changes: 1 addition & 1 deletion dots/grpc/gserver/gin_nobl.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type ginNobl struct {
func GinNoblTypeLives() []*dot.TypeLives {

tl := &dot.TypeLives{
Meta: dot.Metadata{TypeId: GinNoblTypeId, NewDoter: func(conf interface{}) (dot dot.Dot, err error) {
Meta: dot.Metadata{TypeId: GinNoblTypeId, NewDoter: func(conf []byte) (dot dot.Dot, err error) {
return &ginNobl{}, nil
}},
Lives: []dot.Live{
Expand Down
13 changes: 3 additions & 10 deletions dots/grpc/gserver/http_nobl.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,9 @@ type httpNobl struct {
}

//Construct component
func newHttpNobl(conf interface{}) (dot.Dot, error) {
var err error = nil
var bs []byte = nil
if bt, ok := conf.([]byte); ok {
bs = bt
} else {
return nil, dot.SError.Parameter
}
func newHttpNobl(conf []byte) (dot.Dot, error) {
dconf := &httpNoblConf{}
err = dot.UnMarshalConfig(bs, dconf)
err := dot.UnMarshalConfig(conf, dconf)
if err != nil {
return nil, err
}
Expand All @@ -71,7 +64,7 @@ func newHttpNobl(conf interface{}) (dot.Dot, error) {
func HttpNoblTypeLives() []*dot.TypeLives {

tl := &dot.TypeLives{
Meta: dot.Metadata{TypeId: HttpTypeId, NewDoter: func(conf interface{}) (dot dot.Dot, err error) {
Meta: dot.Metadata{TypeId: HttpTypeId, NewDoter: func(conf []byte) (dot dot.Dot, err error) {
return newHttpNobl(conf)
}},
Lives: []dot.Live{
Expand Down

0 comments on commit 2ba9d58

Please sign in to comment.