@@ -31,10 +31,8 @@ type clientSubscriptions struct {
3131// mailbox servers. It manages subscriptions and message queues for each client
3232// and provides a unified interface for receiving messages.
3333type MultiSubscription struct {
34- // baseClientConfig holds the basic configuration for the mailbox
35- // clients. All fields except the ServerAddress are used to create
36- // new mailbox clients when needed.
37- baseClientConfig ClientConfig
34+ // cfg holds the configuration for the MultiSubscription instance.
35+ cfg MultiSubscriptionConfig
3836
3937 // clients holds the active mailbox clients, keyed by their server URL.
4038 clients map [url.URL ]* clientSubscriptions
@@ -48,15 +46,24 @@ type MultiSubscription struct {
4846 sync.RWMutex
4947}
5048
49+ // MultiSubscriptionConfig holds the configuration parameters for creating a
50+ // MultiSubscription instance.
51+ type MultiSubscriptionConfig struct {
52+ // baseClientConfig holds the basic configuration for the mailbox
53+ // clients. All fields except the ServerAddress are used to create
54+ // new mailbox clients when needed.
55+ BaseClientConfig ClientConfig
56+ }
57+
5158// NewMultiSubscription creates a new MultiSubscription instance.
52- func NewMultiSubscription (baseClientConfig ClientConfig ) * MultiSubscription {
59+ func NewMultiSubscription (cfg MultiSubscriptionConfig ) * MultiSubscription {
5360 queue := lfn.NewConcurrentQueue [* ReceivedMessages ](lfn .DefaultQueueSize )
5461 queue .Start ()
5562
5663 return & MultiSubscription {
57- baseClientConfig : baseClientConfig ,
58- clients : make (map [url.URL ]* clientSubscriptions ),
59- msgQueue : queue ,
64+ cfg : cfg ,
65+ clients : make (map [url.URL ]* clientSubscriptions ),
66+ msgQueue : queue ,
6067 }
6168}
6269
@@ -69,7 +76,7 @@ func (m *MultiSubscription) Subscribe(ctx context.Context, serverURL url.URL,
6976
7077 // We hold the mutex for access to common resources.
7178 m .Lock ()
72- cfgCopy := m .baseClientConfig
79+ cfgCopy := m .cfg . BaseClientConfig
7380 client , ok := m .clients [serverURL ]
7481
7582 // If this is the first time we're seeing a server URL, we first create
0 commit comments