fix: need to hack the condtructor and make a global var as the constructor is getting called twice?
This commit is contained in:
parent
3a49375638
commit
64c3795876
|
@ -11,9 +11,9 @@ import (
|
|||
"git.lumeweb.com/LumeWeb/portal/storage"
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/fx"
|
||||
"go.uber.org/fx/fxevent"
|
||||
_"go.uber.org/fx/fxevent"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
_"go.uber.org/zap/zapcore"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -37,13 +37,13 @@ func main() {
|
|||
|
||||
fx.Decorate(func() *zap.Logger {
|
||||
return logger
|
||||
}),
|
||||
}),/*
|
||||
fx.WithLogger(func(logger *zap.Logger) fxevent.Logger {
|
||||
log := &fxevent.ZapLogger{Logger: logger}
|
||||
log.UseLogLevel(zapcore.InfoLevel)
|
||||
log.UseErrorLevel(zapcore.ErrorLevel)
|
||||
return log
|
||||
}),
|
||||
}),*/
|
||||
fx.Invoke(initCheckRequiredConfig),
|
||||
fx.Provide(NewIdentity),
|
||||
db.Module,
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
var (
|
||||
_ s5storage.ProviderStore = (*S5ProviderStore)(nil)
|
||||
_ registry.Protocol = (*S5Protocol)(nil)
|
||||
instance *S5ProtocolResult
|
||||
)
|
||||
|
||||
type S5Protocol struct {
|
||||
|
@ -62,6 +63,9 @@ var ProtocolModule = fx.Module("s5_api",
|
|||
func NewS5Protocol(
|
||||
params S5ProtocolParams,
|
||||
) (S5ProtocolResult, error) {
|
||||
if instance != nil {
|
||||
return *instance, nil
|
||||
}
|
||||
proto := &S5Protocol{
|
||||
config: params.Config,
|
||||
logger: params.Logger,
|
||||
|
@ -74,12 +78,14 @@ func NewS5Protocol(
|
|||
return S5ProtocolResult{}, err
|
||||
}
|
||||
|
||||
return S5ProtocolResult{
|
||||
instance = &S5ProtocolResult{
|
||||
Protocol: proto,
|
||||
S5Protocol: proto,
|
||||
S5NodeConfig: cfg,
|
||||
Db: cfg.DB,
|
||||
}, nil
|
||||
}
|
||||
|
||||
return *instance, nil
|
||||
}
|
||||
|
||||
func ConfigureS5Protocol(params S5ProtocolParams) (*s5config.NodeConfig, error) {
|
||||
|
|
Loading…
Reference in New Issue