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 MapSpec ¶
type MapSpec[K comparable, T any] interface { StateFor(subject Subject) MapState[K, T] }
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 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 ValueSpec ¶
type ValueSpec[T any] interface { StateFor(subject Subject) ValueState[T] }
type ValueState ¶
type ValueState[T any] interface { Value() T Set(value T) Drop() }
Click to show internal directories.
Click to hide internal directories.