예제 #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
}
예제 #2
0
파일: io_irc_sqs.go 프로젝트: dglloyd/ygor
// 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
}