<commit_before>package worker

import (
	"encoding/json"
	"sync"
)

type memoryMessage struct {
	ID uint64
	*Envelope
}

func newMemoryMessage(id uint64, payload []byte) (*memoryMessage, error) {
	base, err := NewEnvelope(payload)
	if err != nil {
		return nil, err
	}

	env := &memoryMessage{
		ID:       id,
		Envelope: base,
	}

	return env, nil
}

// MemoryQueue represents an ordered queue,
// this queue is used in unit tests only.
type MemoryQueue struct {
	sync.Mutex
	size uint64
	l    []*memoryMessage
}

func NewMemoryQueue() Queue {
	return &MemoryQueue{
		l: []*memoryMessage{},
	}
}

func (q *MemoryQueue) Put(j Job) error {
	q.Lock()
	defer q.Unlock()

	typ, err := StructType(j)
	if err != nil {
		return err
	}

	job := &Payload{<commit_msg>Update comment<commit_after>package worker

import (
	"encoding/json"
	"sync"
)

type memoryMessage struct {
	ID uint64
	*Envelope
}

func newMemoryMessage(id uint64, payload []byte) (*memoryMessage, error) {
	base, err := NewEnvelope(payload)
	if err != nil {
		return nil, err
	}

	env := &memoryMessage{
		ID:       id,
		Envelope: base,
	}

	return env, nil
}

// MemoryQueue represents an ordered queue,
// this queue is used mainly for unit tests.
type MemoryQueue struct {
	sync.Mutex
	size uint64
	l    []*memoryMessage
}

func NewMemoryQueue() Queue {
	return &MemoryQueue{
		l: []*memoryMessage{},
	}
}

func (q *MemoryQueue) Put(j Job) error {
	q.Lock()
	defer q.Unlock()

	typ, err := StructType(j)
	if err != nil {
		return err
	}

	job := &Payload{
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.007894736842105263, 'mean_word_length': 3.553892215568862, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1481053', 'n_tokens_mistral': 564, 'n_tokens_neox': 541, 'n_words': 166}