mirror of
https://github.com/psviderski/uncloud.git
synced 2026-10-06 13:18:58 +00:00
feat(store): improve waiting for store replication to skip unavailable members
This commit is contained in:
1 parent
0e53f505c0
commit
e4bd1ad443
7 files changed
+76
-26
No files matched your search
@@ -13,6 +13,8 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const adminCommandTimeout = 5 * time.Second
|
||||
|
||||
// AdminClient is a client for the Corrosion admin API.
|
||||
type AdminClient struct {
|
||||
sockPath string
|
||||
@@ -32,10 +34,15 @@ type Response struct {
|
||||
// The channel will be closed after sending the last or error response. The caller must read from the channel until
|
||||
// it is closed.
|
||||
func (c *AdminClient) SendCommand(cmd []byte) (<-chan Response, error) {
|
||||
conn, err := net.Dial("unix", c.sockPath)
|
||||
// TODO: Accept contexts in admin methods so callers can cancel requests and set their deadlines.
|
||||
conn, err := net.DialTimeout("unix", c.sockPath, adminCommandTimeout)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("connect to admin socket: %w", err)
|
||||
}
|
||||
if err = conn.SetDeadline(time.Now().Add(adminCommandTimeout)); err != nil {
|
||||
conn.Close()
|
||||
return nil, fmt.Errorf("set admin connection deadline: %w", err)
|
||||
}
|
||||
|
||||
if _, err = conn.Write(encodeFrame(cmd)); err != nil {
|
||||
conn.Close()
|
||||
|
||||
Reference in new issue
Block a user