Refactor network to a top-level module

This commit is contained in:
9seconds
2021-03-14 21:43:30 +03:00
parent 37a78bd1c3
commit f8ad90c845
25 changed files with 231 additions and 192 deletions
+28 -1
View File
@@ -1,5 +1,32 @@
package mtglib
import "errors"
import (
"context"
"errors"
"net"
"net/http"
"time"
)
var ErrSecretEmpty = errors.New("secret is empty")
type Network interface {
Dial(network, address string) (net.Conn, error)
DialContext(ctx context.Context, network, address string) (net.Conn, error)
MakeHTTPClient(func(ctx context.Context, network, address string) (net.Conn, error)) *http.Client
IdleTimeout() time.Duration
}
type Logger interface {
Named(name string) Logger
BindInt(name string, value int) Logger
BindStr(name, value string) Logger
Info(msg string)
InfoError(msg string, err error)
Warning(msg string)
WarningError(msg string, err error)
Debug(msg string)
DebugError(msg string, err error)
}