func getPendingMessages(bufferSize int) (result []SMS, err error) { log.Info("getPendingMessages ") allMessages, err := sdb.GetAll(bucket) if err != nil { log.Error(err) return } result = []SMS{} for _, _m := range allMessages { sms := SMS{} err := json.Unmarshal(_m, &sms) if err != nil { log.Error(err) return nil, err } if sms.Status != SMSProcessed && sms.Retries < SMSRetryLimit { result = append(result, sms) } if len(result) >= bufferSize { break } } return }
func GetMessages(filter string) (result []SMS, err error) { log.Info("GetMessages") allMessages, err := sdb.GetAll(bucket) if err != nil { log.Error(err) return } result = []SMS{} for _, _m := range allMessages { sms := SMS{} err := json.Unmarshal(_m, &sms) if err != nil { log.Error("Error when unmarshaling message: ", err) return nil, err } // if sms.Status != SMSProcessed && sms.Retries < SMSRetryLimit { result = append(result, sms) // } } return result, nil }