Beispiel #1
0
func New(mercuryToken, postmarkToken, fromEmailAddress string, kindlegenBinary string, logger *log.Logger) *App {
	return &App{
		kindlegen: kindlegenBinary,
		postmark:  postmark.New(postmarkToken),
		mercury:   mercury.New(mercuryToken, nil),
		from:      fromEmailAddress,
	}
}
Beispiel #2
0
	"golang.org/x/net/html"
)

const (
	FriendlyMessage = "Sorry, extraction failed."
	RetryTimes      = 3
	RetryPause      = 3 * time.Second
)

type JSON map[string]interface{}

var (
	timeout = 5 * time.Second
	token   = env.String("MERCURY_TOKEN")
	logger  = log.New(os.Stdout, "[extractor] ", env.IntDefault("LOG_FLAGS", log.LstdFlags|log.Lmicroseconds))
	merc    = mercury.New(token, logger)
)

type Extractor struct {
	merc   *mercury.Endpoint
	wg     sync.WaitGroup
	Input  <-chan J.Job
	Output chan<- J.Job
	Error  chan<- J.Job
}

func New(merc *mercury.Endpoint, input <-chan J.Job, output chan<- J.Job, error chan<- J.Job) *Extractor {
	return &Extractor{
		merc:   merc,
		Input:  input,
		Output: output,