refactor: switch to using package init functions with build tags to selectively build protocol support
This commit is contained in:
parent
f73ad52864
commit
162af1e274
|
@ -0,0 +1,13 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"git.lumeweb.com/LumeWeb/portal/api/account"
|
||||
"git.lumeweb.com/LumeWeb/portal/api/registry"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry.Register(registry.APIEntry{
|
||||
Key: "account",
|
||||
Module: account.Module,
|
||||
})
|
||||
}
|
13
api/api.go
13
api/api.go
|
@ -6,24 +6,11 @@ import (
|
|||
|
||||
"git.lumeweb.com/LumeWeb/portal/api/middleware"
|
||||
|
||||
"git.lumeweb.com/LumeWeb/portal/api/account"
|
||||
"git.lumeweb.com/LumeWeb/portal/api/registry"
|
||||
"git.lumeweb.com/LumeWeb/portal/api/s5"
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
||||
func RegisterApis() {
|
||||
registry.Register(registry.APIEntry{
|
||||
Key: "s5",
|
||||
Module: s5.Module,
|
||||
})
|
||||
registry.Register(registry.APIEntry{
|
||||
Key: "account",
|
||||
Module: account.Module,
|
||||
})
|
||||
}
|
||||
|
||||
func BuildApis(config *viper.Viper) fx.Option {
|
||||
var options []fx.Option
|
||||
enabledProtocols := config.GetStringSlice("core.protocols")
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
//go:build s5
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"git.lumeweb.com/LumeWeb/portal/api/registry"
|
||||
"git.lumeweb.com/LumeWeb/portal/api/s5"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry.Register(registry.APIEntry{
|
||||
Key: "s5",
|
||||
Module: s5.Module,
|
||||
})
|
||||
}
|
|
@ -34,9 +34,6 @@ func main() {
|
|||
flag.BoolVar(&fxDebug, "fx-debug", false, "Enable fx framework debug logging")
|
||||
flag.Parse()
|
||||
|
||||
protocols.RegisterProtocols()
|
||||
api.RegisterApis()
|
||||
|
||||
var fxLogger fx.Option
|
||||
|
||||
fxLogger = fx.WithLogger(func(logger *zap.Logger) fxevent.Logger {
|
||||
|
|
|
@ -4,20 +4,11 @@ import (
|
|||
"context"
|
||||
|
||||
"git.lumeweb.com/LumeWeb/portal/protocols/registry"
|
||||
"git.lumeweb.com/LumeWeb/portal/protocols/s5"
|
||||
"github.com/samber/lo"
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
||||
func RegisterProtocols() {
|
||||
registry.Register(registry.ProtocolEntry{
|
||||
Key: "s5",
|
||||
Module: s5.ProtocolModule,
|
||||
PreInitFunc: s5.PreInit,
|
||||
})
|
||||
}
|
||||
|
||||
func BuildProtocols(config *viper.Viper) fx.Option {
|
||||
var options []fx.Option
|
||||
enabledProtocols := config.GetStringSlice("core.protocols")
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
//go:build s5
|
||||
|
||||
package protocols
|
||||
|
||||
import (
|
||||
"git.lumeweb.com/LumeWeb/portal/protocols/registry"
|
||||
"git.lumeweb.com/LumeWeb/portal/protocols/s5"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry.Register(registry.ProtocolEntry{
|
||||
Key: "s5",
|
||||
Module: s5.ProtocolModule,
|
||||
PreInitFunc: s5.PreInit,
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue