processors

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: UPL-1.0 Imports: 3 Imported by: 0

Documentation

Overview

Package processors provides various entry processor functions and types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Number

type Number interface {
	~float32 | ~float64 | ~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~complex64 | ~complex128 | big.Rat | big.Int
}

Number represents a type that can be incremented or multiplied

type Processor

type Processor interface {
	// AndThen creates a Processor that executes the current Processor followed by the specified 'next' Processor.
	AndThen(next Processor) Processor

	// When creates a Processor that executes only if the specified Filter passes. If the underlying filter
	// expects to evaluate existent entries only it should be combined with a filter to test for presence
	// like and(present).
	When(filter filters.Filter) Processor
}

Processor interface allows composition of Processors. An instance of a Processor should be created using the various factory methods.

func ConditionalPut

func ConditionalPut[V any](filter filters.Filter, value V) Processor

ConditionalPut puts the value if the filter returns true. While the conditional insert processing could be implemented via direct key-based QueryMap operations, this method is more efficient and enforces concurrency control without explicit locking.

func ConditionalPutAll

func ConditionalPutAll[K comparable, V any](filter filters.Filter, entries map[K]V) Processor

ConditionalPutAll inserts the specified values if the filter evaluates to true. While the conditional insert processing could be implemented via direct key-based QueryMap operations, this is more efficient and enforces concurrency control without explicit locking.

func ConditionalRemove

func ConditionalRemove(filter filters.Filter, returnCurrent ...bool) Processor

ConditionalRemove removes the values if the filter evaluates to true. While the conditional remove could be implemented via direct key-based QueryMap operations, this is more efficient and enforces concurrency control without explicit locking. If returnCurrent is set to true and the remove does not occur, then the current value will be returned.

func Extractor

func Extractor[E any](property string) Processor

Extractor creates a processor to extract the specified property from an entry's value. If the property contains a "." (period), then a chained extractor is created.

func Increment

func Increment[I Number](property string, value I, postInc ...bool) Processor

Increment creates an Increment Processor that increments the numeric value of the specified property by the specified value. If postInc is true then return the value as it was before it was incremented, or if false return the value as it is after it is incremented.

func InvokeAccessor

func InvokeAccessor(method string, args ...interface{}) Processor

InvokeAccessor invokes an accessor method on an entry. The specified method will be invoked with the specified arguments. It returns a Processor that can be used for further composition.

func InvokeMutator

func InvokeMutator(method string, args ...interface{}) Processor

InvokeMutator invokes a mutator method. The specified method will be invoked with the specified arguments. It returns a Processor that can be used for further composition.

func Multiply

func Multiply[I Number](property string, value I, postInc ...bool) Processor

Multiply creates a Multiply Processor that multiplies the numeric value of the specified property by the specified value. If postInc is true then return the value as it was before it was incremented, or if false return the value as it is after it is incremented.

func Preload

func Preload() Processor

Preload loads an entry into a NamedMap. This processor provides a means to "pre-load" an entry or a collection of entries into the cache without incurring the cost of sending the value(s) over the network. If the corresponding entry (or entries) already exists in the map, or if the map does not have a loader, then invoking this Processor has no effect.

func QueueNameHashProcessor added in v1.2.0

func QueueNameHashProcessor(queueName string) Processor

QueueNameHashProcessor determines the hash for a given queue name.

func QueueOfferProcessor added in v1.2.0

func QueueOfferProcessor[V any](value V) Processor

QueueOfferProcessor places an item at the tail of the queue.

func QueuePeekProcessor added in v1.2.0

func QueuePeekProcessor() Processor

QueuePeekProcessor peeks at the first item from the head of the queue.

func QueuePollProcessor added in v1.2.0

func QueuePollProcessor() Processor

QueuePollProcessor retrieves an item from the head of the queue.

func Touch

func Touch() Processor

Touch touches an entry (if present) in order to trigger interceptor re-evaluation and possibly increment expiry time.

func Update

func Update[V any](property string, value V) Processor

Update modifies an entry's specified property with the specified value. The processor will return a bool indicating if the entry to be updated was present.

func VersionedPut

func VersionedPut[V any](value V, canInsert, returnCurrent bool) Processor

VersionedPut inserts the specified value if the version specified by the new value matches the version of the current value. If insertion occurs the version of the entry within the map will be incremented.

func VersionedPutAll

func VersionedPutAll[K comparable, V any](entries map[K]V, canInsert, returnCurrent bool) Processor

VersionedPutAll inserts the specified value if the version specified by the new value matches the version of the current value. If insertion occurs the version of the entry within the map will be incremented.

Jump to

Keyboard shortcuts

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