mirror of
https://github.com/crazybber/go-pattern-examples.git
synced 2024-11-23 04:16:02 +03:00
18 lines
439 B
Go
18 lines
439 B
Go
package messaging
|
|
|
|
//Queue hold all topics
|
|
type Queue struct {
|
|
Topics map[string]Topic //topic ID<-----> topic Object
|
|
}
|
|
|
|
//AddTopic to Queue
|
|
func (q *Queue) AddTopic(topicName string, topicUserQueueSize int) Topic {
|
|
if q.Topics == nil {
|
|
q.Topics = make(map[string]Topic)
|
|
}
|
|
if _, found := q.Topics[topicName]; !found {
|
|
q.Topics[topicName] = Topic{UserQueueSize: topicUserQueueSize, Name: topicName}
|
|
}
|
|
return q.Topics[topicName]
|
|
}
|