<commit_before>package exchangemock

import (
	"sync"

	"nimona.io/pkg/exchange"
)

type (
	MockSubscriptionSimple struct {
		mutex   sync.Mutex
		index   int
		Objects []*exchange.Envelope
	}
)

// Cancel the subscription
func (s *MockSubscriptionSimple) Cancel() {
}

// Next returns the next object
func (s *MockSubscriptionSimple) Next() (*exchange.Envelope, error) {
	s.mutex.Lock()
	defer s.mutex.Unlock()
	if s.index >= len(s.Objects) {
		return nil, nil
	}<commit_msg>chore(exchange): return err when no more mocked envelopes<commit_after>package exchangemock

import (
	"sync"

	"nimona.io/pkg/errors"
	"nimona.io/pkg/exchange"
)

type (
	MockSubscriptionSimple struct {
		mutex   sync.Mutex
		index   int
		Objects []*exchange.Envelope
		done    chan struct{}
	}
)

// Cancel the subscription
func (s *MockSubscriptionSimple) Cancel() {
	select {
	case s.done <- struct{}{}:
	default:
	}
}

// Next returns the next object
func (s *MockSubscriptionSimple) Next() (*exchange.Envelope, error) {
	s.mutex.Lock()
	defer s.mutex.Unlock()
	if s.index >= len(s.Objects) {
		s.done <- struct{}{}
		return nil, errors.New("done")
	}
{'fraction_non_alphanumeric': 0.13503971756398941, 'fraction_numerical': 0.0, 'mean_word_length': 3.866952789699571, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7238811', 'n_tokens_mistral': 419, 'n_tokens_neox': 402, 'n_words': 100}