Exemplo n.º 1
0
func (c *config) toApp() (*app, error) {
	// Retrieve an AWS auth.
	auth, err := awsutil.GetAuth("sqs-notify")
	if err != nil {
		return nil, err
	}

	// Determine a region.
	region, ok := aws.Regions[c.region]
	if !ok {
		return nil, errors.New("unknown region:" + c.region)
	}

	// logfile and pidfile.
	var l *log.Logger
	if len(c.logfile) > 0 {
		if c.logfile == "-" {
			l = log.New(os.Stdout, "", log.LstdFlags)
		} else {
			w := hupwriter.New(c.logfile, c.pidfile)
			l = log.New(w, "", log.LstdFlags)
		}
	}

	notify := sqsnotify.New(auth, region, c.queue)

	jobs, err := c.newJobs()
	if err != nil {
		return nil, err
	}

	return &app{
		logger:   l,
		auth:     auth,
		region:   region,
		worker:   c.worker,
		nowait:   c.nowait,
		retryMax: c.retryMax,
		jobs:     jobs,
		notify:   notify,
		cmd:      c.cmd,
		args:     c.args,
	}, nil
}
Exemplo n.º 2
0
func (c *config) toApp() (*app, error) {
	// Retrieve an AWS auth.
	auth, err := awsutil.GetAuth("sqs-notify")
	if err != nil {
		return nil, err
	}

	// Determine a region.
	region, ok := aws.Regions[c.region]
	if !ok {
		return nil, errors.New("unknown region:" + c.region)
	}

	sqsnotify.Logger = c.logger()
	notify := sqsnotify.New(auth, region, c.queue)

	jobs, err := c.newJobs()
	if err != nil {
		return nil, err
	}

	return &app{
		logger:        c.logger(),
		auth:          auth,
		region:        region,
		worker:        c.worker,
		nowait:        c.nowait,
		ignoreFailure: c.ignoreFailure,
		messageCount:  c.messageCount,
		digestID:      c.digestID,
		retryMax:      c.retryMax,
		jobs:          jobs,
		notify:        notify,
		cmd:           c.cmd,
		args:          c.args,
	}, nil
}