-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: introduce new files for dependency injection
- Add a new file `impl.go` in the `scan` directory - Add a new file `wire.go` in the `scan` directory - Add a new file `wire_gen.go` in the `scan` directory - Add a new file `injector.go` in the `wirex` directory - Update `go.mod` to include `github.com/google/wire v0.6.0` Signed-off-by: Sean Zheng <[email protected]>
- Loading branch information
Showing
6 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package scan | ||
|
||
import ( | ||
"github.com/blackhorseya/ryze/adpater/block/wirex" | ||
"github.com/blackhorseya/ryze/pkg/adapterx" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
type restful struct { | ||
injector *wirex.Injector | ||
} | ||
|
||
// NewRestful is used to create a new adapterx.Restful | ||
func NewRestful(injector *wirex.Injector) adapterx.Restful { | ||
return &restful{ | ||
injector: injector, | ||
} | ||
} | ||
|
||
func (i *restful) Start() error { | ||
// TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (i *restful) AwaitSignal() error { | ||
// TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (i *restful) InitRouting() error { | ||
// TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (i *restful) GetRouter() *gin.Engine { | ||
// TODO implement me | ||
panic("implement me") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//go:build wireinject | ||
|
||
//go:generate wire | ||
|
||
package scan | ||
|
||
import ( | ||
"github.com/blackhorseya/ryze/adpater/block/wirex" | ||
"github.com/blackhorseya/ryze/app/infra/configx" | ||
"github.com/blackhorseya/ryze/pkg/adapterx" | ||
"github.com/google/wire" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func New(v *viper.Viper) (adapterx.Restful, error) { | ||
panic(wire.Build( | ||
wire.Struct(new(wirex.Injector), "*"), | ||
configx.NewConfiguration, | ||
|
||
NewRestful, | ||
)) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package wirex | ||
|
||
import ( | ||
"github.com/blackhorseya/ryze/app/infra/configx" | ||
) | ||
|
||
// Injector is the injector for wirex | ||
type Injector struct { | ||
C *configx.Configuration | ||
|
||
// other fields | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters