This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

appview/repo: reuse knotmirror http client

+40 -28
+1 -2
appview/repo/artifact.go
··· 22 22 comatproto "github.com/bluesky-social/indigo/api/atproto" 23 23 "github.com/bluesky-social/indigo/atproto/syntax" 24 24 lexutil "github.com/bluesky-social/indigo/lex/util" 25 - indigoxrpc "github.com/bluesky-social/indigo/xrpc" 26 25 "github.com/dustin/go-humanize" 27 26 "github.com/go-chi/chi/v5" 28 27 "github.com/go-git/go-git/v5/plumbing" ··· 308 307 return nil, err 309 308 } 310 309 311 - xrpcc := &indigoxrpc.Client{Host: rp.config.KnotMirror.Url} 310 + xrpcc := rp.knotMirrorXRPCClient() 312 311 313 312 xrpcBytes, err := tangled.GitTempListTags(ctx, xrpcc, "", 0, f.RepoDid) 314 313 if err != nil {
+3 -5
appview/repo/blob.go
··· 21 21 "tangled.org/core/types" 22 22 xrpcclient "tangled.org/core/xrpc/xrpcclient" 23 23 24 - "github.com/bluesky-social/indigo/util" 25 - indigoxrpc "github.com/bluesky-social/indigo/xrpc" 26 24 "github.com/go-chi/chi/v5" 27 25 enry "github.com/go-enry/go-enry/v2" 28 26 "github.com/go-git/go-git/v5/plumbing" ··· 60 58 61 59 ctx := r.Context() 62 60 63 - xrpcc := &indigoxrpc.Client{Host: rp.config.KnotMirror.Url} 61 + xrpcc := rp.knotMirrorXRPCClient() 64 62 resp, err := tangled.GitTempGetEntry(ctx, xrpcc, filePath, ref, f.RepoDid) 65 63 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 66 64 l.Error("failed to call XRPC git.getEntry", "xrpcerr", xrpcerr, "err", err) ··· 97 95 if err != nil { 98 96 return models.BlobView{}, err 99 97 } 100 - blobResp, err := util.RobustHTTPClient().Do(blobReq) 98 + blobResp, err := rp.knotMirrorXRPCClient().Client.Do(blobReq) 101 99 if err != nil { 102 100 return models.BlobView{}, err 103 101 } ··· 253 251 w.WriteHeader(http.StatusInternalServerError) 254 252 return 255 253 } 256 - resp, err := util.RobustHTTPClient().Do(req) 254 + resp, err := rp.knotMirrorXRPCClient().Client.Do(req) 257 255 if err != nil || resp.StatusCode != http.StatusOK { 258 256 w.WriteHeader(http.StatusBadGateway) 259 257 return
+1 -3
appview/repo/branches.go
··· 10 10 "tangled.org/core/appview/pages" 11 11 "tangled.org/core/types" 12 12 xrpcclient "tangled.org/core/xrpc/xrpcclient" 13 - 14 - indigoxrpc "github.com/bluesky-social/indigo/xrpc" 15 13 ) 16 14 17 15 func (rp *Repo) Branches(w http.ResponseWriter, r *http.Request) { ··· 21 19 l.Error("failed to get repo and knot", "err", err) 22 20 return 23 21 } 24 - xrpcc := &indigoxrpc.Client{Host: rp.config.KnotMirror.Url} 22 + xrpcc := rp.knotMirrorXRPCClient() 25 23 26 24 xrpcBytes, err := tangled.GitTempListBranches(r.Context(), xrpcc, "", 0, f.RepoDid) 27 25 if err != nil {
+1 -1
appview/repo/compare.go
··· 30 30 return 31 31 } 32 32 33 - xrpcc := &indigoxrpc.Client{Host: rp.config.KnotMirror.Url} 33 + xrpcc := rp.knotMirrorXRPCClient() 34 34 35 35 branchBytes, err := tangled.GitTempListBranches(r.Context(), xrpcc, "", 0, f.RepoDid) 36 36 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+2 -3
appview/repo/feed.go
··· 18 18 19 19 "github.com/bluesky-social/indigo/atproto/identity" 20 20 "github.com/bluesky-social/indigo/atproto/syntax" 21 - indigoxrpc "github.com/bluesky-social/indigo/xrpc" 22 21 "github.com/gorilla/feeds" 23 22 ) 24 23 ··· 207 206 } 208 207 209 208 func (rp *Repo) createCommitItems(ctx context.Context, repo *models.Repo, ownerSlashRepo string) ([]*feeds.Item, error) { 210 - xrpcc := &indigoxrpc.Client{Host: rp.config.KnotMirror.Url} 209 + xrpcc := rp.knotMirrorXRPCClient() 211 210 212 211 xrpcBytes, err := tangled.GitTempListCommits(ctx, xrpcc, "", 100, "", repo.RepoDid) 213 212 if err != nil { ··· 246 245 } 247 246 248 247 func (rp *Repo) createTagItems(ctx context.Context, repo *models.Repo, ownerSlashRepo string) ([]*feeds.Item, error) { 249 - xrpcc := &indigoxrpc.Client{Host: rp.config.KnotMirror.Url} 248 + xrpcc := rp.knotMirrorXRPCClient() 250 249 251 250 tagBytes, err := tangled.GitTempListTags(ctx, xrpcc, "", 100, repo.RepoDid) 252 251 if err != nil {
+2 -6
appview/repo/index.go
··· 16 16 "encoding/json" 17 17 18 18 "github.com/bluesky-social/indigo/atproto/syntax" 19 - indigoxrpc "github.com/bluesky-social/indigo/xrpc" 20 19 "github.com/go-git/go-git/v5/plumbing" 21 20 "tangled.org/core/api/tangled" 22 21 "tangled.org/core/appview/commitverify" ··· 232 231 ref string, 233 232 ) ([]*tangled.GitTempListLanguages_Language, error) { 234 233 // non-fatal, fetch langs from knotmirror via XRPC 235 - xrpcc := &indigoxrpc.Client{ 236 - Host: rp.config.KnotMirror.Url, 237 - Client: http.DefaultClient, 238 - } 234 + xrpcc := rp.knotMirrorXRPCClient() 239 235 out, err := tangled.GitTempListLanguages(ctx, xrpcc, ref, repoId.String()) 240 236 if err != nil { 241 237 return nil, fmt.Errorf("calling knotmirror git.listLanguages: %w", err) ··· 283 279 284 280 // buildIndexResponse creates a RepoIndexResponse by combining multiple xrpc calls in parallel 285 281 func (rp *Repo) buildIndexResponse(ctx context.Context, repo *models.Repo, ref string) (*types.RepoIndexResponse, error) { 286 - xrpcc := &indigoxrpc.Client{Host: rp.config.KnotMirror.Url} 282 + xrpcc := rp.knotMirrorXRPCClient() 287 283 288 284 branchesBytes, err := tangled.GitTempListBranches(ctx, xrpcc, "", 0, repo.RepoDid) 289 285 if err != nil {
+20
appview/repo/knotmirror_client.go
··· 1 + package repo 2 + 3 + import ( 4 + "github.com/bluesky-social/indigo/util" 5 + indigoxrpc "github.com/bluesky-social/indigo/xrpc" 6 + ) 7 + 8 + // newKnotMirrorXRPCClient is created once per Repo service. A nil 9 + // indigoxrpc.Client creates a new RobustHTTPClient for each XRPC call, which 10 + // also creates a new transport and defeats connection reuse. 11 + func newKnotMirrorXRPCClient(host string) *indigoxrpc.Client { 12 + return &indigoxrpc.Client{ 13 + Host: host, 14 + Client: util.RobustHTTPClient(), 15 + } 16 + } 17 + 18 + func (rp *Repo) knotMirrorXRPCClient() *indigoxrpc.Client { 19 + return rp.knotMirrorXRPC 20 + }
+1 -1
appview/repo/log.go
··· 100 100 ref := chi.URLParam(r, "ref") 101 101 ref, _ = url.PathUnescape(ref) 102 102 103 - xrpcc := &indigoxrpc.Client{Host: rp.config.KnotMirror.Url} 103 + xrpcc := rp.knotMirrorXRPCClient() 104 104 105 105 limit := int64(60) 106 106 cursor := ""
+5 -1
appview/repo/repo.go
··· 40 40 "github.com/bluesky-social/indigo/atproto/atclient" 41 41 "github.com/bluesky-social/indigo/atproto/syntax" 42 42 lexutil "github.com/bluesky-social/indigo/lex/util" 43 - 43 + indigoxrpc "github.com/bluesky-social/indigo/xrpc" 44 44 "github.com/go-chi/chi/v5" 45 45 ) 46 46 ··· 59 59 cfClient *cloudflare.Client 60 60 ogreClient *ogre.Client 61 61 codesearch *codesearch.CodeSearch 62 + 63 + knotMirrorXRPC *indigoxrpc.Client 62 64 } 63 65 64 66 func New( ··· 89 91 cfClient: cfClient, 90 92 ogreClient: ogre.NewClient(config.Ogre.Host), 91 93 codesearch: codesearch, 94 + 95 + knotMirrorXRPC: newKnotMirrorXRPCClient(config.KnotMirror.Url), 92 96 } 93 97 } 94 98
+1 -1
appview/repo/settings.go
··· 383 383 f, err := rp.repoResolver.Resolve(r) 384 384 user := rp.oauth.GetMultiAccountUser(r) 385 385 386 - xrpcc := &indigoxrpc.Client{Host: rp.config.KnotMirror.Url} 386 + xrpcc := rp.knotMirrorXRPCClient() 387 387 388 388 xrpcBytes, err := tangled.GitTempListBranches(r.Context(), xrpcc, "", 0, f.RepoDid) 389 389 var result types.RepoBranchesResponse
+2 -3
appview/repo/tags.go
··· 15 15 "tangled.org/core/types" 16 16 xrpcclient "tangled.org/core/xrpc/xrpcclient" 17 17 18 - indigoxrpc "github.com/bluesky-social/indigo/xrpc" 19 18 "github.com/go-chi/chi/v5" 20 19 "github.com/go-git/go-git/v5/plumbing" 21 20 ) ··· 27 26 l.Error("failed to get repo and knot", "err", err) 28 27 return 29 28 } 30 - xrpcc := &indigoxrpc.Client{Host: rp.config.KnotMirror.Url} 29 + xrpcc := rp.knotMirrorXRPCClient() 31 30 xrpcBytes, err := tangled.GitTempListTags(r.Context(), xrpcc, "", 0, f.RepoDid) 32 31 if err != nil { 33 32 l.Error("failed to call XRPC repo.tags", "err", err) ··· 89 88 return 90 89 } 91 90 92 - xrpcc := &indigoxrpc.Client{Host: rp.config.KnotMirror.Url} 91 + xrpcc := rp.knotMirrorXRPCClient() 93 92 94 93 xrpcBytes, err := tangled.GitTempGetTag(r.Context(), xrpcc, f.RepoDid, tag) 95 94 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+1 -2
appview/repo/tree.go
··· 16 16 "tangled.org/core/types" 17 17 xrpcclient "tangled.org/core/xrpc/xrpcclient" 18 18 19 - indigoxrpc "github.com/bluesky-social/indigo/xrpc" 20 19 "github.com/go-chi/chi/v5" 21 20 "github.com/go-git/go-git/v5/plumbing" 22 21 ) ··· 36 35 treePath, _ = url.PathUnescape(treePath) 37 36 treePath = strings.TrimSuffix(treePath, "/") 38 37 39 - xrpcc := &indigoxrpc.Client{Host: rp.config.KnotMirror.Url} 38 + xrpcc := rp.knotMirrorXRPCClient() 40 39 xrpcResp, err := tangled.GitTempGetTree(r.Context(), xrpcc, treePath, ref, f.RepoDid) 41 40 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 42 41 l.Error("failed to call XRPC repo.tree", "xrpcerr", xrpcerr, "err", err)