Exemplo n.º 1
0
func changefeed(logger ctxu.Logger, store storage.MetaStore, imageName, changeID string, records int64) ([]byte, error) {
	changes, err := store.GetChanges(changeID, int(records), imageName)
	if err != nil {
		logger.Errorf("%d GET could not retrieve records: %s", http.StatusInternalServerError, err.Error())
		return nil, errors.ErrUnknown.WithDetail(err)
	}
	out, err := json.Marshal(&changefeedResponse{
		NumberOfRecords: len(changes),
		Records:         changes,
	})
	if err != nil {
		logger.Errorf("%d GET could not json.Marshal changefeedResponse", http.StatusInternalServerError)
		return nil, errors.ErrUnknown.WithDetail(err)
	}
	return out, nil
}