Skip to content

Inline sink emit calls#196

Merged
carole-lavillonniere merged 3 commits intomainfrom
refact-pr-127-2
Apr 29, 2026
Merged

Inline sink emit calls#196
carole-lavillonniere merged 3 commits intomainfrom
refact-pr-127-2

Conversation

@carole-lavillonniere
Copy link
Copy Markdown
Collaborator

@carole-lavillonniere carole-lavillonniere commented Apr 23, 2026

Summary

Refactoring addressing suggested improvement #1 from @thrau in this comment #127 (review)

The goal is to make reading the code easier, be more explicit and idiomatic go, and remove some lines of code.

Changes

  • Replace package-level EmitXxx(sink, ...) helpers with direct sink.Emit(output.XxxEvent{...}) calls at all sites
  • Change Event from a generic union constraint to a sealed marker interface (sealedEvent() unexported method), enabling an exported Sink.Emit(event Event) without generics
  • Remove ~88 lines of boilerplate emit helpers; retain SpinnerStart/SpinnerStop/SpinnerStartWithDuration as value constructors (they encode the MinDuration default)

@carole-lavillonniere
Copy link
Copy Markdown
Collaborator Author

@claude review once

Comment thread internal/output/events.go Outdated
@carole-lavillonniere carole-lavillonniere force-pushed the refact-pr-127-2 branch 3 times, most recently from ad41d18 to 5ad97b8 Compare April 23, 2026 12:53
@carole-lavillonniere carole-lavillonniere changed the title inline sink emit calls Inline sink emit calls Apr 23, 2026
@carole-lavillonniere carole-lavillonniere marked this pull request as ready for review April 27, 2026 12:56
Copy link
Copy Markdown
Member

@thrau thrau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really nice refactor to move us towards a more object-oriented codebase! LGTM

@carole-lavillonniere carole-lavillonniere enabled auto-merge (squash) April 29, 2026 07:57
@carole-lavillonniere carole-lavillonniere enabled auto-merge (squash) April 29, 2026 08:32
Copy link
Copy Markdown
Member

@silv-io silv-io left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment thread internal/output/events.go
Comment on lines +79 to +93
// Event is a sealed marker — only event types in this package implement it,
// so Sink.Emit rejects unknown types at compile time.
type Event interface{ sealedEvent() }

func (MessageEvent) sealedEvent() {}
func (SpinnerEvent) sealedEvent() {}
func (ErrorEvent) sealedEvent() {}
func (AuthEvent) sealedEvent() {}
func (InstanceInfoEvent) sealedEvent() {}
func (TableEvent) sealedEvent() {}
func (ResourceSummaryEvent) sealedEvent() {}
func (ContainerStatusEvent) sealedEvent() {}
func (ProgressEvent) sealedEvent() {}
func (UserInputRequestEvent) sealedEvent() {}
func (LogLineEvent) sealedEvent() {}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in-sync, I think we can remove that seal in the future and just define the Event interface more clearly and then move the Events to their domains.
But that's a future optimization.

@carole-lavillonniere carole-lavillonniere merged commit e6d0fdc into main Apr 29, 2026
8 checks passed
@carole-lavillonniere carole-lavillonniere deleted the refact-pr-127-2 branch April 29, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants