Skip to content

Consolidate Channel and MultiChannel code and add new features. Fixes #238#239

Merged
plorenz merged 4 commits intomainfrom
channel-v5
Apr 14, 2026
Merged

Consolidate Channel and MultiChannel code and add new features. Fixes #238#239
plorenz merged 4 commits intomainfrom
channel-v5

Conversation

@plorenz
Copy link
Copy Markdown
Member

@plorenz plorenz commented Mar 12, 2026

  • merges MultiChannel into Channel interface, removing the separate
    multi.go implementation and priority.go
  • replaces UnderlayHandler god-interface with focused interfaces:
    Senders, MessageSourceProvider, UnderlayEventListener, and DialPolicy
  • replaces GroupedUnderlayFactory with DialPolicy interface;
    adds BackoffDialPolicy with exponential backoff, short-lived
    connection detection, MinDialInterval, and LastDialTime()
  • replaces UnderlayConstraints helper with Config.Constraints map
    and automatic constraint enforcement with CAS-guarded re-check
  • adds UnderlayEventListener callbacks with Channel parameter so
    consumers can track underlay state changes
  • adds Config.UnderlayEventListeners for consumer listener registration
  • adds Config.ConstraintStartupDelay for delayed constraint application
  • adds NewSingleChannelWithUnderlay for listener-side callers with
    bare underlays
  • adds MessageQueue, MakeSource1/2/3, and RetryToQueues helpers to
    reduce priority sender boilerplate
  • adds TypedBinding, TypedBindHandler, and TypedReceiveHandler generics
    for type-safe senders access during binding and message handling
  • consolidates binding code into bind.go; handler types into handler.go
  • adds comprehensive test suite (72+ tests across 10 files)
  • adds godoc comments to all exported symbols
  • clears waiters on channel close to release map entries eagerly
  • fixes nil dialPolicy panic in applyConstraints
  • fixes deferred re-check race in constraint enforcement

@plorenz plorenz force-pushed the channel-v5 branch 2 times, most recently from 77abc34 to 9ef96d9 Compare March 13, 2026 13:17
@plorenz plorenz marked this pull request as ready for review March 13, 2026 13:18
@plorenz plorenz requested a review from a team as a code owner March 13, 2026 13:18
@plorenz plorenz force-pushed the channel-v5 branch 2 times, most recently from d54c922 to 1e4cf66 Compare March 14, 2026 14:41
#238

- merges MultiChannel into Channel interface, removing the separate
  multi.go implementation and priority.go
- replaces UnderlayHandler god-interface with focused interfaces:
  Senders, MessageSourceProvider, UnderlayEventListener, and DialPolicy
- replaces GroupedUnderlayFactory with DialPolicy interface;
  adds BackoffDialPolicy with exponential backoff, short-lived
  connection detection, MinDialInterval, and LastDialTime()
- replaces UnderlayConstraints helper with Config.Constraints map
  and automatic constraint enforcement with CAS-guarded re-check
- adds UnderlayEventListener callbacks with Channel parameter so
  consumers can track underlay state changes
- adds Config.UnderlayEventListeners for consumer listener registration
- adds Config.ConstraintStartupDelay for delayed constraint application
- adds NewSingleChannelWithUnderlay for listener-side callers with
  bare underlays
- adds MessageQueue, MakeSource1/2/3, and RetryToQueues helpers to
  reduce priority sender boilerplate
- adds TypedBinding, TypedBindHandler, and TypedReceiveHandler generics
  for type-safe senders access during binding and message handling
- consolidates binding code into bind.go; handler types into handler.go
- adds comprehensive test suite (72+ tests across 10 files)
- adds godoc comments to all exported symbols
- clears waiters on channel close to release map entries eagerly
- fixes nil dialPolicy panic in applyConstraints
- fixes deferred re-check race in constraint enforcement
Comment thread message_source.go Outdated
}

// MakeSource1 returns a MessageSourceF that reads from one queue.
func MakeSource1(closeNotify <-chan struct{}, q1 <-chan Sendable) MessageSourceF {
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.

The MakeSource#() functions are poorly names. They convey no semantics on what they do.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Changed to

  • MakeSingleQueueMessageSource
  • MakeTwoQueueMessageSource
  • MakeThreeQueueMessageSource

Comment thread impl.go Outdated

func (self *waiterMap) clear() {
self.m.Range(func(k, v interface{}) bool {
self.m.Delete(k)
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.

Does size need to be set to 0?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

changed to:

func (self *waiterMap) clear() {
	atomic.StoreInt32(&self.size, 0)
	self.m.Clear()
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the size isn't actually important, because it's only called on close, but it doesn't hurt to be correct

Comment thread heartbeater.go Outdated
Comment on lines 83 to 86
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.

Wrong assignment? Should be CloseUnresponsiveTimeout ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

good catch, fixed

Copy link
Copy Markdown
Member

@andrewpmartinez andrewpmartinez left a comment

Choose a reason for hiding this comment

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

Small pre-existing bug but overall LGTM.

@plorenz plorenz merged commit 057d8a7 into main Apr 14, 2026
6 checks passed
@plorenz plorenz deleted the channel-v5 branch April 14, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants