promote inbox message to a shared type
This commit is contained in:
+4
-11
@@ -9,7 +9,6 @@ import (
|
||||
"log/slog"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Types
|
||||
@@ -55,14 +54,8 @@ type PeerStats struct {
|
||||
Connection transport.ConnectionStats
|
||||
}
|
||||
|
||||
type InboxMessage struct {
|
||||
ID string
|
||||
Data []byte
|
||||
ReceivedAt time.Time
|
||||
}
|
||||
|
||||
type PoolPlugin struct {
|
||||
Inbox chan<- InboxMessage
|
||||
Inbox chan<- types.InboxMessage
|
||||
Events chan<- PoolEvent
|
||||
Errors chan<- error
|
||||
InboxCounter *atomic.Uint64
|
||||
@@ -86,7 +79,7 @@ type Pool struct {
|
||||
id string
|
||||
|
||||
peers map[string]*Peer
|
||||
inbox chan InboxMessage
|
||||
inbox chan types.InboxMessage
|
||||
events chan PoolEvent
|
||||
errors chan error
|
||||
|
||||
@@ -143,7 +136,7 @@ func NewPool(ctx context.Context, id string, config *PoolConfig, handler slog.Ha
|
||||
cancel: cancel,
|
||||
id: id,
|
||||
peers: make(map[string]*Peer),
|
||||
inbox: make(chan InboxMessage, config.InboxBufferSize),
|
||||
inbox: make(chan types.InboxMessage, config.InboxBufferSize),
|
||||
events: make(chan PoolEvent, config.EventsBufferSize),
|
||||
errors: make(chan error, config.ErrorsBufferSize),
|
||||
inboxCounter: &atomic.Uint64{},
|
||||
@@ -166,7 +159,7 @@ func (p *Pool) Peers() []string {
|
||||
return ids
|
||||
}
|
||||
|
||||
func (p *Pool) Inbox() <-chan InboxMessage {
|
||||
func (p *Pool) Inbox() <-chan types.InboxMessage {
|
||||
return p.inbox
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user