inmem

package
v0.0.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultMaxRetries     = 7
	DefaultMaxConcurrency = 32767
)

Default values

View Source
const (
	SuccessRequest = requestCode(iota)
	ErrorRequest
	RequeueRequest
	FatalRequest
	StatusRequest
	InfoRequest
	SetDeadlineRequest
	RequeueActiveRequest
	RequeueSucceededRequest
	RequeueFailedRequest
)

request codes

Variables

View Source
var (
	ErrNilClient = errors.New("uninitialised client")
	ErrInternal  = errors.New("fatal internal error")
)

errors

Functions

func New

func New(cfg *Config) irange.Storage

New returns a new inmem storage engine with the given configuration. If cfg is nil, the default configuration is used.

Types

type Config

type Config struct {
	MaxRetries     int           // the maximum number of times an entry can be retried
	MaxConcurrency int           // the maximum number of simultaneously active entries in a range
	Log            log.Interface // the logger
}

Config describes the configuration options we allow a user to set on an inmem instance.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a new client configuration initialised with the default values.

func SetDefaultConfig

func SetDefaultConfig(c *Config) *Config

SetDefaultConfig sets the default configuration to c and returns the old default configuration. This change will be reflected in future calls to DefaultConfig.

func (*Config) Copy

func (c *Config) Copy() *Config

Copy returns a copy of the configuration.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration, returning an error if there's a problem.

type Entry

type Entry struct {
	// contains filtered or unexported fields
}

Entry holds metadata about an active entry in a range.

func (*Entry) Deadline

func (e *Entry) Deadline() time.Time

Deadline returns the time at which this entry will go stale.

func (*Entry) Failures

func (e *Entry) Failures() int

Failures returns the number of times that this entry has failed.

func (*Entry) ID

func (e *Entry) ID() irange.ID

ID returns the ID of the entry.

func (*Entry) Value

func (e *Entry) Value() int64

Value returns the value of the entry.

type Info

type Info struct {
	// contains filtered or unexported fields
}

Info describes an entry in a range.

func (*Info) AppName

func (inf *Info) AppName() string

AppName returns the application name provided by the client to which this entry was assigned, or the empty string if there is no such client.

func (*Info) Deadline

func (inf *Info) Deadline() time.Time

Deadline returns the time at which this entry will go stale, or the zero time if this entry has not been assigned to a client.

func (*Info) Failures

func (inf *Info) Failures() int

Failures returns the number of times this entry has failed.

func (*Info) Hostname

func (inf *Info) Hostname() string

Hostname returns the hostname provided by the client to which this entry was assigned, or the empty string if there is no such client.

func (*Info) Start

func (inf *Info) Start() time.Time

Start returns the time at which this entry was assigned to a client, or the zero time if there is no such client.

func (*Info) State

func (inf *Info) State() irange.State

State returns the state of this entry.

func (*Info) Value

func (inf *Info) Value() int64

Value returns the value of this entry.

type Status

type Status struct {
	// contains filtered or unexported fields
}

Status describes the status of a range.

func (*Status) Active

func (st *Status) Active() irange.Range

Active returns the active entries.

func (*Status) Failed

func (st *Status) Failed() irange.Range

Failed returns the entries that have failed.

func (*Status) Pending

func (st *Status) Pending() irange.Range

Pending returns the pending entries.

func (*Status) Succeeded

func (st *Status) Succeeded() irange.Range

Succeeded returns the entries that have succeeded.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL