|
@@ -8,7 +8,7 @@ import (
|
|
|
|
|
|
"github.com/fgm/izidic"
|
|
|
|
|
|
- "code.osinet.fr/fgm/sqs_demo/di"
|
|
|
+ "code.osinet.fr/fgm/sqs_demo/services"
|
|
|
)
|
|
|
|
|
|
func main() {
|
|
@@ -18,14 +18,14 @@ func main() {
|
|
|
func main2(w io.Writer, name string, args []string) (exitCode byte) {
|
|
|
ctx := context.Background()
|
|
|
dic := Resolve(w, name, args)
|
|
|
- lister := dic.MustService(di.Lister).(func(ctx context.Context) string)
|
|
|
+ lister := dic.MustService(services.SvcLister).(func(ctx context.Context) string)
|
|
|
qURL := lister(ctx)
|
|
|
|
|
|
if false {
|
|
|
- receiver := dic.MustService(di.Receiver).(func(ctx context.Context, qURL string))
|
|
|
+ receiver := dic.MustService(services.SvcReceiver).(func(ctx context.Context, qURL string))
|
|
|
receiver(ctx, qURL)
|
|
|
}
|
|
|
- consumer := dic.MustService(di.Consumer).(func(ctx context.Context, qURL string) error)
|
|
|
+ consumer := dic.MustService(services.SvcConsumer).(func(ctx context.Context, qURL string) error)
|
|
|
err := consumer(ctx, qURL)
|
|
|
if err != nil {
|
|
|
log.Printf("error in consumer: %v, aborting", err)
|
|
@@ -38,19 +38,19 @@ func main2(w io.Writer, name string, args []string) (exitCode byte) {
|
|
|
|
|
|
func Resolve(w io.Writer, name string, args []string) *izidic.Container {
|
|
|
dic := izidic.New()
|
|
|
- dic.Store("name", name)
|
|
|
- dic.Store("args", args)
|
|
|
- dic.Store("writer", w)
|
|
|
- dic.Store("handler", di.Handler(HandleDummy))
|
|
|
-
|
|
|
- dic.Register(di.Client, di.SQSClientService)
|
|
|
- dic.Register(di.Consumer, di.ConsumerService)
|
|
|
- dic.Register(di.Flags, di.FlagsService)
|
|
|
- dic.Register(di.Lister, di.ListerService)
|
|
|
- dic.Register(di.Logger, di.LoggerService)
|
|
|
- dic.Register(di.Receiver, di.ReceiverService)
|
|
|
-
|
|
|
- dic.MustService(di.Flags) // Store generated params before freeze.
|
|
|
+ dic.Store(services.PName, name)
|
|
|
+ dic.Store(services.PArgs, args)
|
|
|
+ dic.Store(services.PWriter, w)
|
|
|
+ dic.Store("handler", services.Handler(HandleDummy))
|
|
|
+
|
|
|
+ dic.Register(services.SvcClient, services.SQSClientService)
|
|
|
+ dic.Register(services.SvcConsumer, services.ConsumerService)
|
|
|
+ dic.Register(services.SvcFlags, services.FlagsService)
|
|
|
+ dic.Register(services.SvcLister, services.ListerService)
|
|
|
+ dic.Register(services.SvcLogger, services.LoggerService)
|
|
|
+ dic.Register(services.SvcReceiver, services.ReceiverService)
|
|
|
+
|
|
|
+ dic.MustService(services.SvcFlags) // Store generated params before freeze.
|
|
|
dic.Freeze()
|
|
|
return dic
|
|
|
}
|