1
0
Dima 6 mēneši atpakaļ
vecāks
revīzija
c1444ec377
3 mainītis faili ar 55 papildinājumiem un 0 dzēšanām
  1. 12 0
      db/db_config.go
  2. 19 0
      db/readme.md
  3. 24 0
      smtp/readme.md

+ 12 - 0
db/db_config.go

@@ -98,3 +98,15 @@ func WithMaxIdleConns(maxIdleConns uint16) ConfigOption {
 		s.maxIdleConns = maxIdleConns
 	}
 }
+
+func WithMaxConnLifetime(lifetime time.Duration) ConfigOption {
+	return func(s *Config) {
+		s.maxConnLifetime = &lifetime
+	}
+}
+
+func WithMaxIdleConnLifetime(lifetime time.Duration) ConfigOption {
+	return func(s *Config) {
+		s.maxIdleConnLifetime = &lifetime
+	}
+}

+ 19 - 0
db/readme.md

@@ -0,0 +1,19 @@
+
+## Usage example
+
+```
+dbConn, err := db.NewDB(
+    db.NewConfig(
+        db.WithDriver("mysql"),
+        db.WithUsername("username"),
+        db.WithPassword("password"),
+        db.WithDatabase("db"),        
+    ),
+)
+
+if err != nil {
+    // TODO
+}
+
+err = dbConn.Ping()
+```

+ 24 - 0
smtp/readme.md

@@ -0,0 +1,24 @@
+
+## Usage example
+
+```
+client, err := smtp.NewSMTP(
+    smtp.NewConfig(
+        smtp.WithHost("smtp.example.com"),
+        smtp.WithUsername("username"),
+        smtp.WithPassword("password"),
+        smtp.WithPort(587),
+    ),
+)
+
+if err != nil {
+    // TODO
+}
+
+err = client.Send(
+    "recipient@mail.com",
+    "email subject",
+    "email content",
+    false // is HTML content type
+)
+```