Monorepo for Tangled tangled.org

nix,knotmirror: listen & sync local knots from local knotmirror #1200

merged opened by boltless.me targeting master from sl/rvyxvsnxkkql
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3mhk6tzq7rp22
+36 -9
Interdiff #1 #2
flake.nix

This file has not been changed.

knotmirror/knotstream/slurper.go

This file has not been changed.

knotmirror/resyncer.go

This file has not been changed.

nix/modules/knotmirror.nix

This file has not been changed.

nix/pkgs/knotmirror.nix

This file has not been changed.

+2 -2
nix/vm.nix
··· 175 175 in { 176 176 knot = mkDataSyncScripts "/mnt/knot-data" config.services.tangled.knot.stateDir; 177 177 spindle = mkDataSyncScripts "/mnt/spindle-data" (builtins.dirOf config.services.tangled.spindle.server.dbPath); 178 - knotmirror.after = ["postgresql.service"]; 179 - tap-knotmirror.after = ["postgresql.service"]; 178 + knotmirror.after = ["postgresql.target"]; 179 + tap-knotmirror.after = ["postgresql.target"]; 180 180 }; 181 181 }) 182 182 ];
+17 -5
knotmirror/models/models.go
··· 85 85 HostStatusBanned, 86 86 } 87 87 88 + func (h *Host) URL() string { 89 + if h.NoSSL { 90 + return fmt.Sprintf("http://%s", h.Hostname) 91 + } else { 92 + return fmt.Sprintf("https://%s", h.Hostname) 93 + } 94 + } 95 + 96 + func (h *Host) WsURL() string { 97 + if h.NoSSL { 98 + return fmt.Sprintf("ws://%s", h.Hostname) 99 + } else { 100 + return fmt.Sprintf("wss://%s", h.Hostname) 101 + } 102 + } 103 + 88 104 // func (h *Host) SubscribeGitRefsURL(cursor int64) string { 89 105 // scheme := "wss" 90 106 // if h.NoSSL { ··· 98 114 // } 99 115 100 116 func (h *Host) LegacyEventsURL(cursor int64) string { 101 - scheme := "wss" 102 - if h.NoSSL { 103 - scheme = "ws" 104 - } 105 - u := fmt.Sprintf("%s://%s/events", scheme, h.Hostname) 117 + u := fmt.Sprintf("%s/events", h.WsURL()) 106 118 if cursor > 0 { 107 119 u = fmt.Sprintf("%s?cursor=%d", u, cursor) 108 120 }
+17 -2
knotmirror/tapclient.go
··· 8 8 "log/slog" 9 9 "net/netip" 10 10 "net/url" 11 + "strings" 11 12 "time" 12 13 13 14 "tangled.org/core/api/tangled" ··· 78 79 return fmt.Errorf("parsing record: %w", err) 79 80 } 80 81 82 + knotUrl := record.Knot 83 + if !strings.Contains(record.Knot, "://") { 84 + if host, _ := db.GetHost(ctx, t.db, record.Knot); host != nil { 85 + knotUrl = host.URL() 86 + } else { 87 + t.logger.Warn("repo is from unknown knot") 88 + if t.cfg.KnotUseSSL { 89 + knotUrl = "https://" + knotUrl 90 + } else { 91 + knotUrl = "http://" + knotUrl 92 + } 93 + } 94 + } 95 + 81 96 status := models.RepoStatePending 82 97 errMsg := "" 83 - u, err := url.Parse("http://" + record.Knot) // parsing with fake scheme 98 + u, err := url.Parse(knotUrl) 84 99 if err != nil { 85 100 status = models.RepoStateSuspended 86 101 errMsg = "failed to parse knot url" ··· 94 109 Rkey: evt.Rkey, 95 110 Cid: evt.CID, 96 111 Name: record.Name, 97 - KnotDomain: record.Knot, 112 + KnotDomain: knotUrl, 98 113 State: status, 99 114 ErrorMsg: errMsg, 100 115 RetryAfter: 0, // clear retry info

History

7 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
nix,knotmirror: listen & sync local knots from local knotmirror
2/3 timeout, 1/3 success
expand
expand 0 comments
pull request successfully merged
1 commit
expand
nix,knotmirror: listen & sync local knots from local knotmirror
2/3 timeout, 1/3 success
expand
expand 0 comments
1 commit
expand
nix,knotmirror: listen & sync local knots from local knotmirror
2/3 timeout, 1/3 success
expand
expand 0 comments
1 commit
expand
nix,knotmirror: listen & sync local knots from local knotmirror
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
nix,knotmirror: listen & sync local knots from local knotmirror
expand 0 comments
1 commit
expand
nix,knotmirror: listen & sync local knots from local knotmirror
expand 0 comments
1 commit
expand
nix,knotmirror: listen & sync local knots from local knotmirror
expand 0 comments