feat: add initial uber fx support

This commit is contained in:
Derrick Hammer 2024-01-29 02:16:14 -05:00
parent cc53e61918
commit 722f130072
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 45 additions and 0 deletions

45
fx/fx.go Normal file
View File

@ -0,0 +1,45 @@
package fx
import (
"git.lumeweb.com/LumeWeb/libs5-go/node"
"git.lumeweb.com/LumeWeb/libs5-go/service"
"go.uber.org/fx"
)
var Module = fx.Module("libs5",
fx.Provide(newP2P),
fx.Provide(newRegistry),
fx.Provide(newHTTP),
fx.Provide(newStorage),
fx.Provide(newServices),
fx.Provide(node.NewNode),
)
type ServiceParams struct {
fx.In
service.ServiceParams
}
type ServicesParams struct {
fx.In
node.ServicesParams
}
func newP2P(params ServiceParams) *service.P2PService {
return service.NewP2P(params.ServiceParams)
}
func newRegistry(params ServiceParams) *service.RegistryService {
return service.NewRegistry(params.ServiceParams)
}
func newHTTP(params ServiceParams) *service.HTTPService {
return service.NewHTTP(params.ServiceParams)
}
func newStorage(params ServiceParams) *service.StorageService {
return service.NewStorage(params.ServiceParams)
}
func newServices(params ServicesParams) service.Services {
return node.NewServices(params.ServicesParams)
}