mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-15 02:12:55 +01:00
Add initial connection pool interface
Introduces a new `connpool.go` file implementing a connection pool interface for managing network connections. This interface includes methods to get and close connections, as well as to retrieve the current pool size. The implementation is initially based on a fork of code from the Fatih Arslan GitHub repository.
This commit is contained in:
parent
580d0b0e4e
commit
5ec8a5a5fe
1 changed files with 27 additions and 0 deletions
27
connpool.go
Normal file
27
connpool.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
// SPDX-FileCopyrightText: 2022-2024 The go-mail Authors
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package mail
|
||||
|
||||
import "net"
|
||||
|
||||
// Parts of the connection pool code is forked from https://github.com/fatih/pool/
|
||||
// Thanks to Fatih Arslan and the project contributors for providing this great
|
||||
// concurrency template.
|
||||
|
||||
// Pool interface describes a connection pool implementation. A Pool is
|
||||
// thread-/go-routine safe.
|
||||
type Pool interface {
|
||||
// Get returns a new connection from the pool. Closing the connections returns
|
||||
// it back into the Pool. Closing a connection when the Pool is destroyed or
|
||||
// full will be counted as an error.
|
||||
Get() (net.Conn, error)
|
||||
|
||||
// Close closes the pool and all its connections. After Close() the pool is
|
||||
// no longer usable.
|
||||
Close()
|
||||
|
||||
// Len returns the current number of connections of the pool.
|
||||
Len() int
|
||||
}
|
Loading…
Reference in a new issue