<commit_before>package mq

import (
	"errors"
	"fmt"
	"strconv"

	"golang.org/x/net/context"
)

// Timeout is the number of seconds until a message reservation times out. Max is 86,400
type Timeout uint32

// String converts a timeout value to a printable string
func (t Timeout) String() string {
	return strconv.Itoa(int(t))
}

// Wait is the number of seconds to wait for a message. Max is 30
type Wait uint16

// String converts a wait value to a printable string
func (w Wait) String() string {
	return strconv.Itoa(int(w))
}

func waitInRange(w Wait) bool {
	return w <= MaxWait && w >= MinWait
}

func timeoutInRange(t Timeout) bool {
	return t <= MaxTimeout && t >= MinTimeout
}

const (
	// MinTimeout is the minimum value for a Timeout
	MinTimeout Timeout = 30
	// MaxTimeout is the maximum value for a Timeout
	MaxTimeout Timeout = 86400
	// MinWait is the minimum value for a Wait
	MinWait Wait = 0
	// MaxWait is the maximum value for a wait
	MaxWait Wait = 30
)

var (
	// ErrTimeoutOutOfRange is returned when a Timeout is given that's out of the [MinTimeout, MaxTimeout] range
	ErrTimeoutOutOfRange = fmt.Errorf("timeout out of range [%d, %d]", MinTimeout, MaxTimeout)
	// ErrWaitOutOfRange is returned when a Wait is given that's out of the [MinWait, MaxTimeout] range
	ErrWaitOutOfRange = fmt.Errorf("wait out of range [%d, %d]", MinWait, MaxWait)
	// ErrNoSuchReservation is returned from funcs that accept a reservation ID
	// when the ID doesn't exist
	ErrNoSuchReservation = errors.New("no such reservation")
	// ErrNoSuchMessage is returned from funcs that accept a message ID when the<commit_msg>better docs and 'constructors' for Wait and Timeout<commit_after>package mq

import (
	"errors"
	"fmt"
	"strconv"

	"golang.org/x/net/context"
)

// Timeout is the number of seconds until a message reservation times out. Max is 86,400
type Timeout uint32

// TimeoutFromInt returns a Timeout representation of i if i is in range. Returns ErrTimeoutOutOfRange otherwise
func TimeoutFromInt(i int) (Timeout, error) {
	if i >= MinTimeout && i <= MaxTimeout {
		return Timeout(i), nil
	}
	return 0, ErrTimeoutOutOfRange
}

// String converts a timeout value to a printable string
func (t Timeout) String() string {
	return strconv.Itoa(int(t))
}

// Wait is the number of seconds to wait for a message. Max is 30
type Wait uint16

// WaitFromInt returns a Wait representation of i if i is in range. Returns ErrWaitOutOfRange otherwise.
func WaitFromInt(i int) (Wait, error) {
	if i >= MinWait && i <= MaxWait {
		return Wait(i), nil
	}
	return 0, ErrWaitOutOfRange
}

// String converts a wait value to a printable string
func (w Wait) String() string {
	return strconv.Itoa(int(w))
}

// WaitInRange determines whether the given Wait value is in the valid range
func waitInRange(w Wait) bool {
	return w <= MaxWait && w >= MinWait
}

// TimeoutInRange determines whether the given Timeout value is in the valid range
func timeoutInRange(t Timeout) bool {
	return t <= MaxTimeout && t >= MinTimeout
}

const (
	// MinTimeout is the minimum value for a Timeout
	MinTimeout = 30
	// MaxTimeout is the maximum value for a Timeout
	MaxTimeout = 86400
	// MinWait is the minimum value for a Wait
	MinWait = 0
	// MaxWait is the maximum value for a wait
	MaxWait = 30
)

var (
	// ErrTimeoutOutOfRange is returned when a Timeout is given that's out of the [MinTimeout, MaxTimeout] range
	ErrTimeoutOutOfRange = fmt.Errorf("timeout out of range [%d, %d]", MinTimeout, MaxTimeout)
	// ErrWaitOutOfRange is returned when a Wait is given that's out of the [MinWait, MaxTimeout] range
	ErrWaitOutOfRange = fmt.Errorf("wait out of range [%d, %d]", MinWait, MaxWait)
	// ErrNoSuchReservation is returned from funcs that accept a reservation ID
	// when the ID doesn't exist
	ErrNoSuchReservation = errors.New("no such reservation")
	// ErrNoSuchMessage is returned from funcs that accept a message ID when the
{'fraction_non_alphanumeric': 0.08256646216768916, 'fraction_numerical': 0.011247443762781187, 'mean_word_length': 3.9974457215836527, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5469510', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1192, 'n_words': 522}