Travis J Parker 10 éve
szülő
commit
448487c7df
2 módosított fájl, 21 hozzáadás és 1 törlés
  1. 18 1
      README.md
  2. 3 0
      pool.go

+ 18 - 1
README.md

@@ -55,6 +55,23 @@ e := NewEmail()
 e.AttachFile("test.txt")
 ```
 
+#### A Pool of Reusable Connections
+```
+(var ch <-chan *email.Email)
+p := email.NewPool(
+	"smtp.gmail.com:587",
+	4,
+	smtp.PlainAuth("", "test@gmail.com", "password123", "smtp.gmail.com"),
+)
+for i := 0; i < 4; i++ {
+	go func() {
+		for e := range ch {
+			p.Send(e, 10 * time.Second)
+		}
+	}
+}
+```
+
 ### Documentation
 [http://godoc.org/github.com/jordan-wright/email](http://godoc.org/github.com/jordan-wright/email)
 
@@ -64,4 +81,4 @@ Sections inspired by the handy [gophermail](https://github.com/jpoehls/gophermai
 ### Contributors
 I'd like to thank all the [contributors and maintainers](https://github.com/jordan-wright/email/graphs/contributors) of this package.
 
-A special thanks goes out to Jed Denlea [jeddenlea](https://github.com/jeddenlea) for his numerous contributions and optimizations.
+A special thanks goes out to Jed Denlea [jeddenlea](https://github.com/jeddenlea) for his numerous contributions and optimizations.

+ 3 - 0
pool.go

@@ -221,6 +221,9 @@ func (p *Pool) maybeReplace(err error, c *client) {
 	c.Close()
 }
 
+// Send sends an email via a connection pulled from the Pool. The timeout may
+// be <0 to indicate no timeout. Otherwise reaching the timeout will produce
+// ErrTimeout.
 func (p *Pool) Send(e *Email, timeout time.Duration) (err error) {
 	c := p.get(timeout)
 	if c == nil {