diff options
Diffstat (limited to '')
-rw-r--r-- | forged/internal/ipc/git2c/client.go (renamed from forged/internal/git2c/client.go) | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/forged/internal/git2c/client.go b/forged/internal/ipc/git2c/client.go index ed9390c..8b11035 100644 --- a/forged/internal/git2c/client.go +++ b/forged/internal/ipc/git2c/client.go @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -// Package git2c provides routines to interact with the git2d backend daemon. package git2c import ( + "context" "fmt" "net" - "go.lindenii.runxiyu.org/forge/forged/internal/bare" + "go.lindenii.runxiyu.org/forge/forged/internal/common/bare" ) // Client represents a connection to the git2d backend daemon. @@ -20,8 +20,9 @@ type Client struct { } // NewClient establishes a connection to a git2d socket and returns a new Client. -func NewClient(socketPath string) (*Client, error) { - conn, err := net.Dial("unix", socketPath) +func NewClient(ctx context.Context, socketPath string) (*Client, error) { + dialer := &net.Dialer{} //exhaustruct:ignore + conn, err := dialer.DialContext(ctx, "unix", socketPath) if err != nil { return nil, fmt.Errorf("git2d connection failed: %w", err) } @@ -38,9 +39,12 @@ func NewClient(socketPath string) (*Client, error) { } // Close terminates the underlying socket connection. -func (c *Client) Close() error { +func (c *Client) Close() (err error) { if c.conn != nil { - return c.conn.Close() + err = c.conn.Close() + if err != nil { + return fmt.Errorf("close underlying socket: %w", err) + } } return nil } |