package main import ( "context" "io" "log" "os" "github.com/fgm/izidic" services2 "code.osinet.fr/fgm/sqs_demo/back/services" ) func main() { os.Exit(int(main2(os.Stdout, os.Args[0], os.Args[1:]))) } func main2(w io.Writer, name string, args []string) (exitCode byte) { ctx := context.Background() dic := Resolve(w, name, args) lister := dic.MustService(services2.SvcLister).(func(ctx context.Context) string) qURL := lister(ctx) producer := dic.MustService(services2.SvcProducer).(func(ctx context.Context, qName string)) producer(ctx, qURL) log.Printf("exiting cleanly") return 0 } func Resolve(w io.Writer, name string, args []string) *izidic.Container { dic := izidic.New() dic.Store(services2.PName, name) dic.Store(services2.PArgs, args) dic.Store(services2.PWriter, w) dic.Register(services2.SvcClient, services2.SQSClientService) dic.Register(services2.SvcFlags, services2.FlagsService) dic.Register(services2.SvcLister, services2.ListerService) dic.Register(services2.SvcLogger, services2.LoggerService) dic.Register(services2.SvcProducer, services2.ProducerService) dic.MustService(services2.SvcFlags) // Store generated params before freeze. dic.Freeze() return dic }