diff options
Diffstat (limited to '')
-rw-r--r-- | forged/internal/ipc/git2c/client.go (renamed from forged/internal/git2c/client.go) | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/forged/internal/git2c/client.go b/forged/internal/ipc/git2c/client.go index ed9390c..79c2024 100644 --- a/forged/internal/git2c/client.go +++ b/forged/internal/ipc/git2c/client.go @@ -1,17 +1,16 @@ // 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. type Client struct { socketPath string conn net.Conn @@ -19,9 +18,9 @@ type Client struct { reader *bare.Reader } -// 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) } @@ -37,10 +36,12 @@ func NewClient(socketPath string) (*Client, error) { }, nil } -// 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 } |