refactor: change Registry name to EntryRegistry

This commit is contained in:
Derrick Hammer 2024-03-17 08:36:32 -04:00
parent 61012ae394
commit a85ced7c62
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
4 changed files with 9 additions and 9 deletions

View File

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

View File

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

View File

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

View File

@ -8,7 +8,7 @@ import (
) )
func init() { func init() {
registry.Register(registry.APIEntry{ registry.RegisterEntry(registry.APIEntry{
Key: "s5", Key: "s5",
Module: s5.Module, Module: s5.Module,
}) })