Esempio n. 1
0
// StartMinionAdapter is the entry point for this IO adapter. It reads from the
// main ygord queue and assume all the incoming messages are minion feedbacks.
func (srv *Server) StartMinionAdapter(client *sqs.Client, queueName string) (<-chan error, error) {
	errch := make(chan error, 0)

	ch, sqserrch, err := sqschan.Incoming(client, queueName)
	if err != nil {
		return nil, err
	}

	go func() {
		for {
			select {
			case sqsmsg := <-ch:
				msg := NewMessageFromMinionSQS(sqsmsg)
				srv.InputQueue <- msg
				err := client.DeleteMessage(sqsmsg)
				if err != nil {
					errch <- err
				}
			case err := <-sqserrch:
				errch <- err
			}
		}
	}()

	return errch, nil
}
Esempio n. 2
0
// StartIRCIncomingQueueReader reads all input from the IRC incoming queue
// passing errors to the error channel.
func StartIRCIncomingQueueReader(client *sqs.Client) (<-chan error, error) {
	errch := make(chan error, 0)

	ch, sqserrch, err := sqschan.Incoming(client, cfg.IRCIncomingQueueName)
	if err != nil {
		return nil, err
	}

	go func() {
		for {
			select {
			case sqsmsg := <-ch:
				err := ReceiveSQSMessageForIRC(client, sqsmsg)
				if err != nil {
					errch <- err
				}
			case err := <-sqserrch:
				errch <- err
			}
		}
	}()

	return errch, nil
}