diff options
author | Runxi Yu <me@runxiyu.org> | 2025-08-12 11:01:07 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-09-15 15:19:12 +0800 |
commit | eb82fdb2dc0903e6125014abd64aceab42c8eb35 (patch) | |
tree | c07276ba1595c415ebc28943163d88f3e3180254 /forged/internal/ipc/git2c/client.go | |
parent | Remove forge-specific functions from misc (diff) | |
download | forge-eb82fdb2dc0903e6125014abd64aceab42c8eb35.tar.gz forge-eb82fdb2dc0903e6125014abd64aceab42c8eb35.tar.zst forge-eb82fdb2dc0903e6125014abd64aceab42c8eb35.zip |
Refactor
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 } |