aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/imap/client.go25
-rw-r--r--internal/imap/imap.go6
2 files changed, 12 insertions, 19 deletions
diff --git a/internal/imap/client.go b/internal/imap/client.go
index 4a0a0d8..5d36373 100644
--- a/internal/imap/client.go
+++ b/internal/imap/client.go
@@ -21,13 +21,12 @@ type connConf struct {
type Client struct {
connConf
- mailboxes *mailboxes
- commander *commander
- connections []*connection
- maxConnections int
- connChannel chan *connection
- connLock sync.Mutex
- disconnected bool
+ mailboxes *mailboxes
+ commander *commander
+ connections []*connection
+ connChannel chan *connection
+ connLock sync.Mutex
+ disconnected bool
}
var dialer imapClient.Dialer
@@ -105,10 +104,6 @@ func (cl *Client) Disconnect() {
func (cl *Client) createConnection(c *imapClient.Client) *connection {
- if len(cl.connections) == cl.maxConnections {
- panic("Too many connections")
- }
-
client := &client{c, uidplus.NewClient(c)}
conn := &connection{
@@ -121,11 +116,9 @@ func (cl *Client) createConnection(c *imapClient.Client) *connection {
return conn
}
-func newClient(maxConnections int) *Client {
+func newClient() *Client {
return &Client{
- mailboxes: NewMailboxes(),
- connChannel: make(chan *connection, 0),
- connections: make([]*connection, 0, maxConnections),
- maxConnections: maxConnections,
+ mailboxes: NewMailboxes(),
+ connChannel: make(chan *connection, 0),
}
}
diff --git a/internal/imap/imap.go b/internal/imap/imap.go
index 80a37a1..1179f3d 100644
--- a/internal/imap/imap.go
+++ b/internal/imap/imap.go
@@ -7,10 +7,10 @@ import (
"github.com/Necoro/feed2imap-go/pkg/log"
)
-func Connect(url config.Url, maxConnections int) (*Client, error) {
+func Connect(url config.Url, numConnections int) (*Client, error) {
var err error
- client := newClient(maxConnections)
+ client := newClient()
client.host = url.Host
defer func() {
if err != nil {
@@ -41,7 +41,7 @@ func Connect(url config.Url, maxConnections int) (*Client, error) {
}
// the other connections
- for i := 1; i < client.maxConnections; i++ {
+ for i := 1; i < numConnections; i++ {
go func(id int) {
if _, err := client.connect(url); err != nil { // explicitly new var 'err', b/c these are now harmless
log.Warnf("connecting #%d: %s", id, err)