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