pubsub

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB represents the main database connection

func Connect

func Connect(ctx context.Context, config common.Config) (*DB, error)

Connect is the main entry point for connecting to the P2P pubsub network

func (*DB) ConnectedPeers

func (db *DB) ConnectedPeers() []*peer.AddrInfo

ConnectedPeers returns information about connected peers

func (*DB) Disconnect

func (db *DB) Disconnect(ctx context.Context) error

Disconnect closes the database connection and cleans up resources

func (*DB) GetHost

func (db *DB) GetHost() host.Host

GetHost returns the underlying libp2p host

func (*DB) IsReady

func (db *DB) IsReady() bool

IsReady returns true if the node has at least 1 peer connected

func (*DB) Publish

func (db *DB) Publish(ctx context.Context, topic string, value interface{}) (common.Event, error)

Publish publishes a message to a topic

func (*DB) Subscribe

func (db *DB) Subscribe(ctx context.Context, topic string, handler common.PubSubHandler) error

Subscribe subscribes to a topic and starts listening for messages

func (*DB) Unsubscribe

func (db *DB) Unsubscribe(ctx context.Context, topic string) error

Unsubscribe unsubscribes from a topic and stops listening for messages

type DatabaseInstance

type DatabaseInstance struct {
	// contains filtered or unexported fields
}

DatabaseInstance represents a database instance with isolated topics

type DiscoveryService

type DiscoveryService struct {
	// contains filtered or unexported fields
}

DiscoveryService provides peer discovery functionality

func NewDiscoveryService

func NewDiscoveryService(host host.Host, dht *dual.DHT, logger common.Logger) *DiscoveryService

NewDiscoveryService creates a new discovery service

func (*DiscoveryService) GetConnectedPeers

func (ds *DiscoveryService) GetConnectedPeers() []peer.AddrInfo

GetConnectedPeers returns information about currently connected peers

func (*DiscoveryService) GetDHTStats

func (ds *DiscoveryService) GetDHTStats() map[string]interface{}

GetDHTStats returns DHT statistics

func (*DiscoveryService) StartDiscovery

func (ds *DiscoveryService) StartDiscovery(ctx context.Context, databaseName string) error

StartDiscovery starts the discovery process for a database

func (*DiscoveryService) StartTopicDiscovery added in v1.0.6

func (ds *DiscoveryService) StartTopicDiscovery(ctx context.Context, databaseName, topic string) error

StartTopicDiscovery starts topic-specific peer discovery for GossipSub mesh formation

func (*DiscoveryService) StopTopicDiscovery added in v1.0.6

func (ds *DiscoveryService) StopTopicDiscovery(topic string)

StopTopicDiscovery stops topic-specific peer discovery

type P2PInfrastructure

type P2PInfrastructure struct {
	// contains filtered or unexported fields
}

P2PInfrastructure manages the libp2p resources for a single database connection

func (*P2PInfrastructure) IsReady

func (infra *P2PInfrastructure) IsReady() bool

IsReady returns true if the node has at least 1 peer connected

type TopicSubscription

type TopicSubscription struct {
	// contains filtered or unexported fields
}

TopicSubscription manages a topic subscription

Jump to

Keyboard shortcuts

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