Organize backend into product executable and shared Go modules
This commit is contained in:
1 parent
981e84a4b4
commit
f0720ec66b
382 files changed
+1944
-6989
No files matched your search
@@ -0,0 +1,40 @@
|
||||
package serverimp
|
||||
|
||||
import (
|
||||
"git.sendico.io/tech/sxchnge/product/app/process"
|
||||
"git.sendico.io/tech/sxchnge/shared/logging"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type Instance struct {
|
||||
srv server.Application
|
||||
logger mlogger.Logger
|
||||
file string
|
||||
debug bool
|
||||
factory server.ServerFactoryT
|
||||
}
|
||||
|
||||
func (i *Instance) Start() error {
|
||||
var err error
|
||||
if i.srv, err = i.factory(i.logger, i.file, i.debug); err != nil {
|
||||
i.logger.Warn("Failed to create server instance", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
return i.srv.Start()
|
||||
}
|
||||
|
||||
func (i *Instance) Shutdown() {
|
||||
if i.srv != nil {
|
||||
i.srv.Shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
func NewInstance(factory server.ServerFactoryT, logger mlogger.Logger, file string, debug bool) *Instance {
|
||||
return &Instance{
|
||||
srv: nil,
|
||||
logger: logger,
|
||||
file: file,
|
||||
debug: debug,
|
||||
factory: factory,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user