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() {
registry.Register(registry.APIEntry{
registry.RegisterEntry(registry.APIEntry{
Key: "account",
Module: account.Module,
})

View File

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

View File

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

View File

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