code: func (m *MemoryBackend) Subscribe(client *Client, subs []packet.Subscription, ack Ack) error {
  	// acquire global mutex
  	m.globalMutex.Lock()
  	defer m.globalMutex.Unlock()
  
  	// save subscription
  	for _, sub := range subs {
  		client.Session().(*memorySession).subscriptions.Set(sub.Topic, sub)
  	}
  
  	// call ack if provided
  	if ack != nil {
  		ack()
  	}
  
  	// get session
  	sess := client.Session().(*memorySession)
  
  	// handle all subscriptions
  	for _, sub := range subs {
  		// get retained messages
  		values := m.retainedMessages.Search(sub.Topic)
  
  		// publish messages
  		for _, value := range values {
  			// add to temporary queue or return error if queue is full
  			select {
  			case sess.temporary <- value.(*packet.Message):
  			default:
  				return ErrQueueFull
  			}
  		}
  	}
  
  	return nil
  }
docs: // Subscribe will store the subscription and queue retained messages.