aboutsummaryrefslogtreecommitdiff
path: root/factory
diff options
context:
space:
mode:
Diffstat (limited to 'factory')
-rw-r--r--factory/factory.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/factory/factory.go b/factory/factory.go
index 2acac39..ad3262e 100644
--- a/factory/factory.go
+++ b/factory/factory.go
@@ -6,13 +6,15 @@ import (
"github.com/rs/zerolog"
+ "www.thenautilus.net/cgit/go-example/business"
"www.thenautilus.net/cgit/go-example/config"
"www.thenautilus.net/cgit/go-example/logging"
"www.thenautilus.net/cgit/go-example/something"
)
type Factory struct {
- something *something.Something
+ somethingClient *something.Something
+ businessLogic *business.Logic
config *config.MainConfig
logger zerolog.Logger
@@ -43,13 +45,25 @@ func (f *Factory) Logger() zerolog.Logger {
return f.logger
}
-func (f *Factory) Something() *something.Something {
- if f.something == nil {
+func (f *Factory) SomethingClient() *something.Something {
+ if f.somethingClient == nil {
something := something.New(
&f.config.Something,
)
- f.something = &something
+ f.somethingClient = &something
}
- return f.something
+ return f.somethingClient
+}
+
+func (f *Factory) BusinessLogic() *business.Logic {
+ if f.businessLogic == nil {
+ logic := business.New(
+ &f.config.BusinessLogic,
+ f.SomethingClient(),
+ )
+ f.businessLogic = &logic
+ }
+
+ return f.businessLogic
}