feat(store): improve waiting for store replication to skip unavailable members

This commit is contained in:
Pasha Sviderski committed 2026-10-01 20:59:15 +10:00
1 parent 0e53f505c0
commit e4bd1ad443
7 files changed
+76 -26

No files matched your search

+8 -1
View File
@@ -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()