Documentation
¶
Overview ¶
Package store provides pubsub state backends for GoSPA.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("key not found")
ErrNotFound is returned when a key is not found in the storage.
Functions ¶
This section is empty.
Types ¶
type MemoryPubSub ¶
type MemoryPubSub struct {
// contains filtered or unexported fields
}
MemoryPubSub provides an in-memory implementation of the PubSub interface. It is intended for single-process environments where external infrastructure is not needed.
func NewMemoryPubSub ¶
func NewMemoryPubSub() *MemoryPubSub
NewMemoryPubSub creates a new in-memory PubSub system.
func (*MemoryPubSub) Subscribe ¶
func (p *MemoryPubSub) Subscribe(_ context.Context, channel string, handler func(message []byte)) (Unsubscribe, error)
Subscribe registers a handler and returns an Unsubscribe function.
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage provides an in-memory implementation of the Storage interface.
func NewMemoryStorage ¶
func NewMemoryStorage() *MemoryStorage
NewMemoryStorage creates a new in-memory storage.
func (*MemoryStorage) Close ¶ added in v0.1.13
func (s *MemoryStorage) Close() error
Close explicitly stops the background pruning loop to prevent goroutine leaks.
func (*MemoryStorage) Delete ¶
func (s *MemoryStorage) Delete(_ context.Context, key string) error
Delete removes a value from the in-memory store.
type PubSub ¶
type PubSub interface {
Publish(ctx context.Context, channel string, message []byte) error
Subscribe(ctx context.Context, channel string, handler func(message []byte)) (Unsubscribe, error)
}
PubSub represents an external publish-subscribe mechanism for multi-process broadcasting.
type Storage ¶
type Storage interface {
Get(ctx context.Context, key string) ([]byte, error)
Set(ctx context.Context, key string, val []byte, exp time.Duration) error
Delete(ctx context.Context, key string) error
}
Storage represents an external key-value store for session and state data.
type Unsubscribe ¶ added in v0.1.30
type Unsubscribe func()
Unsubscribe is a function to cancel a subscription.