client.go 838 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package main
  2. import (
  3. "fmt"
  4. "math/rand"
  5. "time"
  6. "github.com/flashmob/go-guerrilla/mocks"
  7. )
  8. const (
  9. URL = "127.0.0.1:2500"
  10. )
  11. var (
  12. helos = []string{"hi", "hello", "ahoy", "bonjour", "hey!", "whats up"}
  13. emails = []string{
  14. "[email protected]",
  15. "[email protected]",
  16. "[email protected]",
  17. "[email protected]",
  18. "[email protected]",
  19. "[email protected]",
  20. "[email protected]",
  21. "[email protected]",
  22. "[email protected]",
  23. "[email protected]",
  24. }
  25. )
  26. func main() {
  27. c := make(chan int)
  28. for i := 0; i < 100; i++ {
  29. go sendMailForever(time.Millisecond * time.Duration(rand.Int()%500))
  30. }
  31. <-c
  32. }
  33. func sendMailForever(wait time.Duration) {
  34. c := mocks.Client{
  35. Helo: helos[rand.Int()%len(helos)],
  36. EmailAddress: emails[rand.Int()%len(emails)],
  37. }
  38. fmt.Println(c)
  39. for {
  40. c.SendMail("[email protected]", URL)
  41. time.Sleep(wait)
  42. }
  43. }