go-pattern-examples/gomore/01_messages/message_queue.go

18 lines
439 B
Go
Raw Normal View History

2020-04-30 09:50:21 +03:00
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]
}