New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
log/syslog: About syslog.connect()
The service is abnormal due to an accidental connection failure
#64165
Comments
I think this is working as intended: |
Let's skip the explanation of Dial for a second. Let's look at the services provided by the syslog package. Here are a few of my examples: package dial
import (
"context"
"database/sql"
"testing"
_ "github.com/go-sql-driver/mysql"
"github.com/redis/go-redis/v9"
"google.golang.org/grpc"
)
func TestMySQL(t *testing.T) {
// This connection is invalid
db, err := sql.Open("mysql", "username:password@tcp(hostname:port)/database_name")
if err != nil {
panic(err.Error())
}
defer db.Close()
// test connection
err = db.Ping()
if err == nil {
t.Fatal("expected error") // <--- Success
}
}
func TestGRPC(t *testing.T) {
// This connection is invalid
conn, err := grpc.Dial("hostname:port", grpc.WithInsecure())
if err != nil {
panic(err.Error())
}
defer conn.Close()
// test invoke
err = conn.Invoke(context.Background(), "/service_name", nil, nil)
if err == nil {
t.Fatal("expected error") // <--- Success
}
}
func TestRedis(t *testing.T) {
rdb := redis.NewClient(&redis.Options{
Addr: "hostname:port",
})
// test connection
_, err := rdb.Ping(context.Background()).Result()
if err == nil {
t.Fatal("expected error") // <--- Success
}
} The result:
All in: What I want to say is that as the syslog package, we should provide services and ignore the
|
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Recurrence situation:
I have a service, and syslog.Dial is set up before the service starts. If the syslog server is temporarily unavailable at this time, the whole service cannot be started.
see: #64168
After running
TestDialWhenConnectionIsBad
single measurement resultsWhat did you expect to see?
I want to be able to ignore momentary disconnections without causing an exception to the primary service
What did you see instead?
Instant disconnect, just when the service is started, the service cannot be started
The text was updated successfully, but these errors were encountered: