aboutsummaryrefslogtreecommitdiff
path: root/internal/imap/imap.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2023-06-04 21:55:50 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2023-06-04 22:06:19 +0200
commitc2697725ead29c3c108a8e5f7a9f6ab7519ed7c3 (patch)
treec4432926812476c384ae06feb949887d5f896ed8 /internal/imap/imap.go
parent565b1a1eef18372aa3e75efa47b34aec47a53571 (diff)
downloadfeed2imap-go-c2697725ead29c3c108a8e5f7a9f6ab7519ed7c3.tar.gz
feed2imap-go-c2697725ead29c3c108a8e5f7a9f6ab7519ed7c3.tar.bz2
feed2imap-go-c2697725ead29c3c108a8e5f7a9f6ab7519ed7c3.zip
Add new config option to set max number of IMAP connections.
Default is 5 (as was the hard-coded value before). Closes issue #98.
Diffstat (limited to 'internal/imap/imap.go')
-rw-r--r--internal/imap/imap.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/internal/imap/imap.go b/internal/imap/imap.go
index a44a513..80a37a1 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) (*Client, error) {
+func Connect(url config.Url, maxConnections int) (*Client, error) {
var err error
- client := newClient()
+ client := newClient(maxConnections)
client.host = url.Host
defer func() {
if err != nil {
@@ -41,7 +41,7 @@ func Connect(url config.Url) (*Client, error) {
}
// the other connections
- for i := 1; i < len(client.connections); i++ {
+ for i := 1; i < client.maxConnections; 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)