rxn

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2025 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyedEvent

type KeyedEvent = internal.KeyedEvent

KeyedEvent has a Key used for partitioning data and a timestamp used for tracking time. It's value is arbitrary byte data.

type MapCodec added in v0.0.3

type MapCodec[K comparable, T any] = states.MapCodec[K, T]

type MapSpec

type MapSpec[K comparable, T any] interface {
	StateFor(subject Subject) MapState[K, T]
}

type MapState

type MapState[K comparable, V any] interface {
	Get(key K) (V, bool)
	Set(key K, value V)
	Delete(key K)
	All() iter.Seq2[K, V]
	Size() int
}

type OperatorHandler

type OperatorHandler interface {
	// Called when a new event arrives. The subject is a set of APIs scoped to
	// the specific partition key being used. Because of this scoping, think of this
	// as the subject (e.g. a User, a Product) in your domain.
	OnEvent(ctx context.Context, subject Subject, event KeyedEvent) error

	// A previously set timer expires. This is an asynchronous action where the
	// timer fires at the specified time AT THE EARLIEST. That means that events
	// after the timer's timestamp have likely already arrived.
	OnTimerExpired(ctx context.Context, subject Subject, timer time.Time) error
}

OperatorHandler defines the two methods operators implement to handle events and timers.

type ScalarMapCodec added in v0.0.3

type ScalarMapCodec[K comparable, V any] struct{}

ScalarMapCodec is a concrete MapCodec which uses Protobuf to serialize simple scalar values. Supported types are:

  • int, int32, int64
  • uint, uint32, uint64
  • float32, float64
  • string
  • bool
  • time.Time

func (ScalarMapCodec[K, V]) DecodeKey added in v0.0.3

func (ScalarMapCodec[K, V]) DecodeKey(b []byte) (K, error)

DecodeKey decodes the key using decodeScalar.

func (ScalarMapCodec[K, V]) DecodeValue added in v0.0.3

func (ScalarMapCodec[K, V]) DecodeValue(b []byte) (V, error)

Decode decodes the value using decodeScalar.

func (ScalarMapCodec[K, V]) EncodeKey added in v0.0.3

func (ScalarMapCodec[K, V]) EncodeKey(key K) ([]byte, error)

EncodeKey encodes the key using encodeScalar.

func (ScalarMapCodec[K, V]) EncodeValue added in v0.0.3

func (ScalarMapCodec[K, V]) EncodeValue(value V) ([]byte, error)

Encode encodes the value using encodeScalar.

type ScalarValueCodec added in v0.0.3

type ScalarValueCodec[T states.ProtoScalar] struct{}

func (ScalarValueCodec[T]) Decode added in v0.0.3

func (ScalarValueCodec[T]) Decode(b []byte) (T, error)

func (ScalarValueCodec[T]) Encode added in v0.0.3

func (ScalarValueCodec[T]) Encode(value T) ([]byte, error)

type Sink

type Sink[T any] interface {
	Collect(ctx context.Context, value T)
}

Sink is a generic interface for collecting values.

type Subject

type Subject interface {
	// Timestamp returns the timestamp associated with the current event.
	Timestamp() time.Time
	// Key returns the key associated with the current event.
	Key() []byte
	// SetTimer sets a timer for the current key. After the timer expires, the
	// OnTimerExpired method will be called with this timestamp.
	SetTimer(ts time.Time)
	// Watermark returns the current watermark
	Watermark() time.Time
}

Subject provides APIs for interacting withing the currently keyed scope.

type ValueCodec added in v0.0.3

type ValueCodec[T any] interface {
	Encode(value T) ([]byte, error)
	Decode(b []byte) (T, error)
}

type ValueSpec

type ValueSpec[T any] interface {
	StateFor(subject Subject) ValueState[T]
}

type ValueState

type ValueState[T any] interface {
	Value() T
	Set(value T)
	Drop()
}

Jump to

Keyboard shortcuts

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