topicstore

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

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 NewSimpleStore

func NewSimpleStore() *SimpleStore

NewSimpleStore creates a new SimpleStore.

func (*SimpleStore) Clear

func (s *SimpleStore) Clear()

Clear removes all topics from the store.

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.

type Topic

type Topic interface {
	Close()
}

Topic represents the interface that stored topics must implement. This is a minimal interface to avoid circular dependencies.

Jump to

Keyboard shortcuts

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