Documentation
¶
Overview ¶
Package topicstore provides topic storage implementations for the pubsub package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ShardedStore ¶
type ShardedStore struct {
// contains filtered or unexported fields
}
ShardedStore is a high-performance topic store that distributes topics across multiple shards to reduce lock contention.
func NewShardedStore ¶
func NewShardedStore() *ShardedStore
NewShardedStore creates a new ShardedStore.
func (*ShardedStore) Clear ¶
func (s *ShardedStore) Clear()
Clear removes all topics from the store.
func (*ShardedStore) DeleteTopic ¶
func (s *ShardedStore) DeleteTopic(name string)
DeleteTopic removes a topic and closes all its subscriptions.
func (*ShardedStore) GetOrCreate ¶
func (s *ShardedStore) GetOrCreate(name string, factory func() Topic, onCreated func(Topic)) Topic
GetOrCreate returns an existing topic or creates a new one using the factory.
func (*ShardedStore) Range ¶
func (s *ShardedStore) Range(fn func(name string, topic Topic) bool)
Range iterates over all topics across all shards.
func (*ShardedStore) Shutdown ¶
func (s *ShardedStore) Shutdown(ctx context.Context)
Shutdown closes all topics with context support.
type SimpleStore ¶
type SimpleStore struct {
// contains filtered or unexported fields
}
SimpleStore is a basic topic store using a single mutex-protected map. Suitable for most use cases with moderate topic counts.
func (*SimpleStore) DeleteTopic ¶
func (s *SimpleStore) DeleteTopic(name string)
DeleteTopic removes a topic and closes all its subscriptions.
func (*SimpleStore) GetOrCreate ¶
func (s *SimpleStore) GetOrCreate(name string, factory func() Topic, onCreated func(Topic)) Topic
GetOrCreate returns an existing topic or creates a new one using the factory.
func (*SimpleStore) Range ¶
func (s *SimpleStore) Range(fn func(name string, topic Topic) bool)
Range iterates over all topics.
func (*SimpleStore) Shutdown ¶
func (s *SimpleStore) Shutdown(ctx context.Context)
Shutdown closes all topics with context support.
type Store ¶
type Store interface {
// GetOrCreate returns an existing topic or creates a new one using the factory.
GetOrCreate(name string, factory func() Topic, onCreated func(Topic)) Topic
// Range iterates over all topics. Return false from fn to stop iteration.
Range(fn func(name string, topic Topic) bool)
// DeleteTopic removes a topic and closes all its subscriptions.
DeleteTopic(name string)
// Shutdown closes all topics with context for timeout support.
Shutdown(ctx context.Context)
}
Store defines the interface for topic storage backends. Implementations must be safe for concurrent use.