refactor: change Registry name to EntryRegistry
This commit is contained in:
parent
61012ae394
commit
a85ced7c62
|
@ -6,7 +6,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.Register(registry.APIEntry{
|
registry.RegisterEntry(registry.APIEntry{
|
||||||
Key: "account",
|
Key: "account",
|
||||||
Module: account.Module,
|
Module: account.Module,
|
||||||
})
|
})
|
||||||
|
|
|
@ -15,7 +15,7 @@ var alwaysEnabled = []string{"account"}
|
||||||
func BuildApis(cm *config.Manager) fx.Option {
|
func BuildApis(cm *config.Manager) fx.Option {
|
||||||
var options []fx.Option
|
var options []fx.Option
|
||||||
enabledProtocols := cm.Viper().GetStringSlice("core.protocols")
|
enabledProtocols := cm.Viper().GetStringSlice("core.protocols")
|
||||||
for _, entry := range registry.GetRegistry() {
|
for _, entry := range registry.GetEntryRegistry() {
|
||||||
if slices.Contains(enabledProtocols, entry.Key) || slices.Contains(alwaysEnabled, entry.Key) {
|
if slices.Contains(enabledProtocols, entry.Key) || slices.Contains(alwaysEnabled, entry.Key) {
|
||||||
options = append(options, entry.Module)
|
options = append(options, entry.Module)
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ type LifecyclesParams struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetupLifecycles(lifecycle fx.Lifecycle, params LifecyclesParams) error {
|
func SetupLifecycles(lifecycle fx.Lifecycle, params LifecyclesParams) error {
|
||||||
for _, entry := range registry.GetRegistry() {
|
for _, entry := range registry.GetEntryRegistry() {
|
||||||
for _, protocol := range params.Protocols {
|
for _, protocol := range params.Protocols {
|
||||||
if protocol.Name() == entry.Key {
|
if protocol.Name() == entry.Key {
|
||||||
lifecycle.Append(fx.Hook{
|
lifecycle.Append(fx.Hook{
|
||||||
|
|
|
@ -19,19 +19,19 @@ type APIEntry struct {
|
||||||
Module fx.Option
|
Module fx.Option
|
||||||
}
|
}
|
||||||
|
|
||||||
var apiRegistry []APIEntry
|
var apiEntryRegistry []APIEntry
|
||||||
var router *router2.APIRouter
|
var router *router2.APIRouter
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
router = router2.NewAPIRouter()
|
router = router2.NewAPIRouter()
|
||||||
}
|
}
|
||||||
|
|
||||||
func Register(entry APIEntry) {
|
func RegisterEntry(entry APIEntry) {
|
||||||
apiRegistry = append(apiRegistry, entry)
|
apiEntryRegistry = append(apiEntryRegistry, entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRegistry() []APIEntry {
|
func GetEntryRegistry() []APIEntry {
|
||||||
return apiRegistry
|
return apiEntryRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRouter() *router2.APIRouter {
|
func GetRouter() *router2.APIRouter {
|
||||||
|
|
Loading…
Reference in New Issue