cloudwego / hertz

Go HTTP framework with high-performance and strong-extensibility for building micro-services.
https://www.cloudwego.io
Apache License 2.0
5.28k stars 515 forks source link

how to create a client connection to unix domain socket? #1194

Closed sprappcom closed 1 month ago

sprappcom commented 1 month ago

something like... ? client.WithNetwork("unix"), // <- here doesnt work like this. my backendAddr is "unix:///home/ubuntu/web.sock"

                        newPool = &sync.Pool{
                                New: func() interface{} {
                                        cli, err := client.NewClient(
                                                client.WithDialTimeout(1*time.Second),
                                                client.WithMaxConnsPerHost(10240),
                                                client.WithMaxIdleConnDuration(30*time.Second),
                                                client.WithMaxConnDuration(0),
                                                client.WithMaxConnWaitTimeout(10*time.Second),
                                                client.WithKeepAlive(true),
                                                client.WithNetwork("unix"), // <- here doesnt work like this. my backendAddr is "unix:///home/ubuntu/web.sock"
                                                client.WithClientReadTimeout(60*time.Second),
                                                client.WithWriteTimeout(60*time.Second),
                                                client.WithDialer(standard.NewDialer()),
                                                client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}),
                                                client.WithHostClientConfigHook(func(hc interface{}) error {
                                                        if hct, ok := hc.(*http1.HostClient); ok {
                                                                hct.Addr = backendAddr
                                                        }
                                                        return nil
                                                }),
                                        )
                                        if err != nil {
                                                log.Fatalf("failed to create client for %s: %v", backendAddr, err)
                                        }
                                        return cli
                                },
                        }

latest ubuntu 24.04, latest golang, latest hertz

github-actions[bot] commented 1 month ago

This issue has been marked as invalid question, please give more information by following the issue template. The issue will be closed in 1 days if no further activity occurs.