diff --git a/server/gitea/client.go b/server/gitea/client.go index 8e245b0..e936aae 100644 --- a/server/gitea/client.go +++ b/server/gitea/client.go @@ -9,8 +9,6 @@ import ( "github.com/valyala/fasthttp" "github.com/valyala/fastjson" - - "codeberg.org/codeberg/pages/server/shared" ) const giteaAPIRepos = "/api/v1/repos/" @@ -46,7 +44,7 @@ func (client *Client) GiteaRawContent(targetOwner, targetRepo, ref, resource str req.Header.Set(fasthttp.HeaderAuthorization, client.giteaAPIToken) res := fasthttp.AcquireResponse() - if err := shared.GetFastHTTPClient(10*time.Second).Do(req, res); err != nil { + if err := getFastHTTPClient(10*time.Second).Do(req, res); err != nil { return nil, err } if res.StatusCode() != fasthttp.StatusOK { @@ -56,7 +54,7 @@ func (client *Client) GiteaRawContent(targetOwner, targetRepo, ref, resource str } func (client *Client) ServeRawContent(uri string) (*fasthttp.Response, error) { - fastClient := shared.GetFastHTTPClient(10 * time.Second) + fastClient := getFastHTTPClient(10 * time.Second) req := fasthttp.AcquireRequest() req.SetRequestURI(path.Join(client.giteaRoot, giteaAPIRepos, uri)) @@ -69,7 +67,7 @@ func (client *Client) ServeRawContent(uri string) (*fasthttp.Response, error) { } func (client *Client) GiteaGetRepoBranchTimestamp(repoOwner, repoName, branchName string) (time.Time, error) { - fastClient := shared.GetFastHTTPClient(5 * time.Second) + fastClient := getFastHTTPClient(5 * time.Second) req := fasthttp.AcquireRequest() req.SetRequestURI(path.Join(client.giteaRoot, giteaAPIRepos, repoOwner, repoName, "branches", branchName)) @@ -86,7 +84,7 @@ func (client *Client) GiteaGetRepoBranchTimestamp(repoOwner, repoName, branchNam } func (client *Client) GiteaGetRepoDefaultBranch(repoOwner, repoName string) (string, error) { - fastClient := shared.GetFastHTTPClient(5 * time.Second) + fastClient := getFastHTTPClient(5 * time.Second) req := fasthttp.AcquireRequest() req.SetRequestURI(path.Join(client.giteaRoot, giteaAPIRepos, repoOwner, repoName)) diff --git a/server/shared/fast_http_client.go b/server/shared/fast_http_client.go deleted file mode 100644 index 0ab655e..0000000 --- a/server/shared/fast_http_client.go +++ /dev/null @@ -1,16 +0,0 @@ -package shared - -import ( - "time" - - "github.com/valyala/fasthttp" -) - -func GetFastHTTPClient(timeout time.Duration) *fasthttp.Client { - return &fasthttp.Client{ - ReadTimeout: timeout, - MaxConnDuration: 60 * time.Second, - MaxConnWaitTimeout: 1000 * time.Millisecond, - MaxConnsPerHost: 128 * 16, // TODO: adjust bottlenecks for best performance with Gitea! - } -}