diff --git a/appview/pipelines/logs.go b/appview/pipelines/logs.go index 5ca9a8dd..0c035d31 100644 --- a/appview/pipelines/logs.go +++ b/appview/pipelines/logs.go @@ -4,7 +4,6 @@ import ( "fmt" "html/template" "net/url" - "path" "regexp" "strings" @@ -94,15 +93,5 @@ func SubscribeLogsUrl(spindle string, pipeline syntax.TID, workflow string) stri query := url.Values{} query.Set("pipeline", pipeline.String()) query.Set("workflow", workflow) - return fmt.Sprintf("%s/xrpc/%s?%s", u, tangled.CiWorkflowSubscribeLogsNSID, query.Encode()) -} - -// TODO(boltless): deprecate this -func SpindleURL(spindle, knot, rkey, workflow string) string { - url, err := hostutil.EnsureWsScheme(spindle) - if err != nil { - return "" - } - - return url + path.Join("/logs", knot, rkey, workflow) + return fmt.Sprintf("%s/xrpc/%s?%s", u, tangled.CiPipelineSubscribeLogsNSID, query.Encode()) } diff --git a/appview/pipelines/notifier.go b/appview/pipelines/notifier.go deleted file mode 100644 index 93759eed..00000000 --- a/appview/pipelines/notifier.go +++ /dev/null @@ -1,52 +0,0 @@ -package pipelines - -import ( - "sync" - - "github.com/bluesky-social/indigo/atproto/syntax" - "tangled.org/core/notifier" -) - -// StatusNotifier is a keyed broadcast notifier for pipeline status changes, keyed by the pipeline's AT URI. -// -// subscribers are notified whenever a status update arrives for that pipeline -type StatusNotifier struct { - mu sync.Mutex - keys map[syntax.ATURI]*notifier.Notifier -} - -func NewStatusNotifier() *StatusNotifier { - return &StatusNotifier{ - keys: make(map[syntax.ATURI]*notifier.Notifier), - } -} - -func (n *StatusNotifier) Publish(uri syntax.ATURI) { - n.mu.Lock() - p, ok := n.keys[uri] - n.mu.Unlock() - if ok { - p.NotifyAll() - } -} - -func (n *StatusNotifier) Subscribe(uri syntax.ATURI) chan struct{} { - n.mu.Lock() - p, ok := n.keys[uri] - if !ok { - nb := notifier.New() - p = &nb - n.keys[uri] = p - } - n.mu.Unlock() - return p.Subscribe() -} - -func (n *StatusNotifier) Unsubscribe(uri syntax.ATURI, ch chan struct{}) { - n.mu.Lock() - p, ok := n.keys[uri] - n.mu.Unlock() - if ok { - p.Unsubscribe(ch) - } -} diff --git a/appview/pipelines/pipelines.go b/appview/pipelines/pipelines.go index 2e760e41..e73bfc9f 100644 --- a/appview/pipelines/pipelines.go +++ b/appview/pipelines/pipelines.go @@ -33,7 +33,6 @@ type Pipelines struct { config *config.Config oauth *oauth.OAuth pages *pages.Pages - pipelineNotifier *StatusNotifier db *db.DB enforcer *rbac.Enforcer logger *slog.Logger @@ -55,7 +54,6 @@ func New( oauth *oauth.OAuth, repoResolver *reporesolver.RepoResolver, pages *pages.Pages, - pipelineNotifier *StatusNotifier, idResolver *idresolver.Resolver, db *db.DB, config *config.Config, @@ -68,7 +66,6 @@ func New( pages: pages, idResolver: idResolver, config: config, - pipelineNotifier: pipelineNotifier, db: db, enforcer: enforcer, logger: logger, diff --git a/appview/pipelines/ssh/logstream.go b/appview/pipelines/ssh/logstream.go index 8d0a3f6a..d9565db8 100644 --- a/appview/pipelines/ssh/logstream.go +++ b/appview/pipelines/ssh/logstream.go @@ -6,14 +6,12 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/gorilla/websocket" "tangled.org/core/appview/pipelines" - spindlemodel "tangled.org/core/spindle/models" ) type step struct { id int name string command string - kind spindlemodel.StepKind lines []string startTime time.Time endTime time.Time diff --git a/appview/pipelines/ssh/server.go b/appview/pipelines/ssh/server.go index 96fff723..4920b7b2 100644 --- a/appview/pipelines/ssh/server.go +++ b/appview/pipelines/ssh/server.go @@ -10,18 +10,16 @@ import ( tea "github.com/charmbracelet/wish/bubbletea" "tangled.org/core/appview/config" "tangled.org/core/appview/db" - "tangled.org/core/appview/pipelines" ) type Server struct { - db *db.DB - config *config.Config - pipelineNotifier *pipelines.StatusNotifier - logger *slog.Logger + db *db.DB + config *config.Config + logger *slog.Logger } -func New(db *db.DB, cfg *config.Config, pn *pipelines.StatusNotifier, logger *slog.Logger) *Server { - return &Server{db: db, config: cfg, pipelineNotifier: pn, logger: logger} +func New(db *db.DB, cfg *config.Config, logger *slog.Logger) *Server { + return &Server{db: db, config: cfg, logger: logger} } func (s *Server) ListenAndServe(ctx context.Context) error { diff --git a/appview/state/router.go b/appview/state/router.go index 927b92a5..e8531567 100644 --- a/appview/state/router.go +++ b/appview/state/router.go @@ -406,7 +406,6 @@ func (s *State) PipelinesRouter(mw *middleware.Middleware) http.Handler { s.oauth, s.repoResolver, s.pages, - s.pipelineNotifier, s.idResolver, s.db, s.config, diff --git a/appview/state/state.go b/appview/state/state.go index ea48bc37..99213f61 100644 --- a/appview/state/state.go +++ b/appview/state/state.go @@ -30,7 +30,6 @@ import ( whnotify "tangled.org/core/appview/notify/webhook" "tangled.org/core/appview/oauth" "tangled.org/core/appview/pages" - "tangled.org/core/appview/pipelines" pipelinessh "tangled.org/core/appview/pipelines/ssh" "tangled.org/core/appview/reporesolver" "tangled.org/core/appview/repoverify" @@ -71,7 +70,6 @@ type State struct { repoResolver *reporesolver.RepoResolver aclService *knotacl.Service knotstream *eventconsumer.Consumer - pipelineNotifier *pipelines.StatusNotifier logger *slog.Logger validator *validator.Validator cfClient *cloudflare.Client @@ -220,10 +218,6 @@ func Make(ctx context.Context, config *config.Config) (*State, error) { } knotstream.Start(ctx) - // TODO: pipeline notifier serves as pipeline store with cache to prevent spamming spindles - // maybe, not super sure... - pipelineNotifier := pipelines.NewStatusNotifier() - state := &State{ db: d, notifier: notifier, @@ -240,7 +234,6 @@ func Make(ctx context.Context, config *config.Config) (*State, error) { repoResolver: repoResolver, aclService: aclService, knotstream: knotstream, - pipelineNotifier: pipelineNotifier, logger: logger, validator: validator, cfClient: cfClient, @@ -258,7 +251,7 @@ func (s *State) Close() error { } func (s *State) NewSSHServer() *pipelinessh.Server { - return pipelinessh.New(s.db, s.config, s.pipelineNotifier, log.SubLogger(s.logger, "pipelinessh")) + return pipelinessh.New(s.db, s.config, log.SubLogger(s.logger, "pipelinessh")) } func (s *State) SecurityTxt(w http.ResponseWriter, r *http.Request) {