code: func (s *RateLimitedSMSService) Send(phonenumber string, message string) (err error) {
  	conn := db.NewSession()
  	if conn == nil {
  		return errors.New("Failed to get DB connection")
  	}
  
  	mgr := smshistory.NewManager(conn)
  
  	sendCount, err := mgr.CountSMSHistorySince(phonenumber, time.Now().Add(-s.window))
  	if err != nil && !db.IsNotFound(err) {
  		log.Error("Failed to count sms history: ", err)
  		return err
  	}
  
  	// if we've send more or equal than max sms count msges already return an error
  	if sendCount >= s.maxSMS {
  		log.Info("Rate limiting sms sending to ", phonenumber, ", already sent ", sendCount, " SMS in the last ", s.window)
  		return ErrMaxSMS
  	}
  
  	// Add log entry
  	record := smshistory.New(phonenumber)
  	if err = mgr.AddSMSHistory(record); err != nil {
  		return err
  	}
  
  	// Send the actual sms
  	return s.actualService.Send(phonenumber, message)
  }
docs: // Send checksif the message can be send according to the rate limiting rules, and then
  // deligates the acutal sender to the wrapped service. This uses a sliding window approach