Monorepo for Tangled tangled.org

appview,knotmirror: use knotmirror to read the repository #1164

merged opened by boltless.me targeting master from sl/knotmirror

Underlying types except the interface hasn't changed much. Removed xrpcclient.HandleXrpcErr() call as appview always expect knotmirror with compatible API.

Signed-off-by: Seongmin Lee git@boltless.me

Labels

None yet.

assignee

None yet.

Participants 3
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3mh3qbj6ygg22
+28 -20
Interdiff #1 #2
appview/config/config.go

This file has not been changed.

appview/pulls/pulls.go

This file has not been changed.

appview/repo/archive.go

This file has not been changed.

appview/repo/artifact.go

This file has not been changed.

appview/repo/branches.go

This file has not been changed.

appview/repo/compare.go

This file has not been changed.

+1 -1
appview/repo/index.go
··· 164 164 xrpcc := &indigoxrpc.Client{Host: rp.config.KnotMirror.Url} 165 165 ls, err := tangled.GitTempListLanguages(ctx, xrpcc, currentRef, repo.RepoAt().String()) 166 166 if err != nil { 167 - return nil, fmt.Errorf("calling knotmirror: %w", err) 167 + return nil, fmt.Errorf("calling knotmirror git.listLanguages: %w", err) 168 168 } 169 169 170 170 if ls == nil || ls.Languages == nil {
appview/repo/log.go

This file has not been changed.

appview/repo/settings.go

This file has not been changed.

appview/repo/tags.go

This file has not been changed.

appview/repo/tree.go

This file has not been changed.

knotmirror/config/config.go

This file has not been changed.

knotmirror/knotmirror.go

This patch was likely rebased, as context lines do not match.

knotmirror/xrpc/git_getArchive.go

This file has not been changed.

knotmirror/xrpc/git_getBlob.go

This file has not been changed.

knotmirror/xrpc/git_getBranch.go

This file has not been changed.

knotmirror/xrpc/git_getTag.go

This file has not been changed.

knotmirror/xrpc/git_getTree.go

This file has not been changed.

knotmirror/xrpc/git_listBranches.go

This file has not been changed.

knotmirror/xrpc/git_listCommits.go

This file has not been changed.

+2 -3
knotmirror/xrpc/git_listLanguages.go
··· 29 29 30 30 out, err := x.listLanguages(r.Context(), repo, ref) 31 31 if err != nil { 32 - // TODO: better error return 33 32 l.Error("failed to list languages", "err", err) 34 - writeJson(w, http.StatusInternalServerError, atclient.ErrorBody{Name: "InternalServerError", Message: "failed to list languages"}) 33 + writeErr(w, err) 35 34 return 36 35 } 37 36 ··· 46 45 47 46 gr, err := git.Open(repoPath, ref) 48 47 if err != nil { 49 - return nil, fmt.Errorf("opening git repo: %w", err) 48 + return nil, &atclient.APIError{StatusCode: http.StatusNotFound, Name: "RepoNotFound", Message: "failed to find git repo"} 50 49 } 51 50 52 51 ctx, cancel := context.WithTimeout(ctx, 1*time.Second)
knotmirror/xrpc/git_listTags.go

This file has not been changed.

+25 -16
knotmirror/xrpc/xrpc.go
··· 3 3 import ( 4 4 "database/sql" 5 5 "encoding/json" 6 + "errors" 6 7 "log/slog" 7 8 "net/http" 8 9 10 + "github.com/bluesky-social/indigo/atproto/atclient" 9 11 "github.com/go-chi/chi/v5" 10 12 "tangled.org/core/api/tangled" 11 13 "tangled.org/core/idresolver" 12 14 "tangled.org/core/knotmirror/config" 15 + "tangled.org/core/log" 13 16 ) 14 17 15 18 type Xrpc struct { ··· 24 27 cfg, 25 28 db, 26 29 resolver, 27 - logger, 30 + log.SubLogger(logger, "xrpc"), 28 31 } 29 32 } 30 33 31 34 func (x *Xrpc) Router() http.Handler { 32 35 r := chi.NewRouter() 33 36 34 - r.Route("/xrpc", func(r chi.Router) { 35 - r.Get("/"+tangled.GitTempGetArchiveNSID, x.GetArchive) 36 - r.Get("/"+tangled.GitTempGetBlobNSID, x.GetBlob) 37 - r.Get("/"+tangled.GitTempGetBranchNSID, x.GetBranch) 38 - // r.Get("/"+tangled.GitTempGetCommitNSID, x.GetCommit) // todo 39 - // r.Get("/"+tangled.GitTempGetDiffNSID, x.GetDiff) // todo 40 - // r.Get("/"+tangled.GitTempGetEntityNSID, x.GetEntity) // todo 41 - // r.Get("/"+tangled.GitTempGetHeadNSID, x.GetHead) // todo 42 - r.Get("/"+tangled.GitTempGetTagNSID, x.GetTag) // using types.Response 43 - r.Get("/"+tangled.GitTempGetTreeNSID, x.GetTree) 44 - r.Get("/"+tangled.GitTempListBranchesNSID, x.ListBranches) // wip, unknown output 45 - r.Get("/"+tangled.GitTempListCommitsNSID, x.ListCommits) 46 - r.Get("/"+tangled.GitTempListLanguagesNSID, x.ListLanguages) 47 - r.Get("/"+tangled.GitTempListTagsNSID, x.ListTags) 48 - }) 37 + r.Get("/"+tangled.GitTempGetArchiveNSID, x.GetArchive) 38 + r.Get("/"+tangled.GitTempGetBlobNSID, x.GetBlob) 39 + r.Get("/"+tangled.GitTempGetBranchNSID, x.GetBranch) 40 + // r.Get("/"+tangled.GitTempGetCommitNSID, x.GetCommit) // todo 41 + // r.Get("/"+tangled.GitTempGetDiffNSID, x.GetDiff) // todo 42 + // r.Get("/"+tangled.GitTempGetEntityNSID, x.GetEntity) // todo 43 + // r.Get("/"+tangled.GitTempGetHeadNSID, x.GetHead) // todo 44 + r.Get("/"+tangled.GitTempGetTagNSID, x.GetTag) // using types.Response 45 + r.Get("/"+tangled.GitTempGetTreeNSID, x.GetTree) 46 + r.Get("/"+tangled.GitTempListBranchesNSID, x.ListBranches) // wip, unknown output 47 + r.Get("/"+tangled.GitTempListCommitsNSID, x.ListCommits) 48 + r.Get("/"+tangled.GitTempListLanguagesNSID, x.ListLanguages) 49 + r.Get("/"+tangled.GitTempListTagsNSID, x.ListTags) 49 50 50 51 return r 51 52 } ··· 58 59 } 59 60 return nil 60 61 } 62 + 63 + func writeErr(w http.ResponseWriter, err error) error { 64 + var apiErr *atclient.APIError 65 + if errors.As(err, &apiErr) { 66 + return writeJson(w, apiErr.StatusCode, atclient.ErrorBody{Name: apiErr.Name, Message: apiErr.Message}) 67 + } 68 + return writeJson(w, http.StatusInternalServerError, atclient.ErrorBody{Name: "InternalServerError", Message: "internal server error"}) 69 + }
knotserver/git/git.go

This file has not been changed.

History

5 rounds 5 comments
sign up or login to add to the discussion
1 commit
expand
appview,knotmirror: use knotmirror to read the repository
2/3 failed, 1/3 success
expand
expand 0 comments
pull request successfully merged
1 commit
expand
appview,knotmirror: use knotmirror to read the repository
expand 0 comments
1 commit
expand
appview,knotmirror: use knotmirror to read the repository
expand 0 comments
1 commit
expand
appview,knotmirror: use knotmirror to read the repository
expand 5 comments

appview/config/config.go:49: can the appview be run without the knotmirror at all?

Yes.

we can't run appview without db syncing atproto repos
we can't run appview without knotmirror syncing git repos

simple as that

knotmirror/xrpc/xrpc.go:34

Just to confirm that this doesn't double up on /xrpc/xrpc/something right?

@lewis.moe Thank you for pointing out. Seems like I changed too much since testing it. I'll resubmit everything after testing everything again.

1 commit
expand
appview,knotmirror: use knotmirror to read the repository
expand 0 comments