hub

package
v0.35.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Message  string
	SenderID string

	Annotations map[string]interface{}
}

Message gets converted to/from JSON and sent in the body of pubsub messages.

func NewMessage

func NewMessage(s string) *Message

func (*Message) AnnotationsToObj added in v0.13.0

func (m *Message) AnnotationsToObj(v interface{}) error

func (*Message) Apply

func (m *Message) Apply(opts ...MessageOption) error

Apply applies the given options to the config, returning the first error encountered (if any).

func (*Message) Copy

func (m *Message) Copy() *Message

func (*Message) WithMessage

func (m *Message) WithMessage(s string) *Message

type MessageHub added in v0.11.0

type MessageHub struct {
	sync.Mutex

	Messages, PublicMessages chan *Message
	// contains filtered or unexported fields
}

func NewHub added in v0.11.0

func NewHub(otp string, maxsize, keyLength, interval int, joinPublic bool, opts ...Option) *MessageHub

func (*MessageHub) ListPeers added in v0.11.0

func (m *MessageHub) ListPeers() ([]peer.ID, error)

func (*MessageHub) PublishMessage added in v0.11.0

func (m *MessageHub) PublishMessage(mess *Message) error

func (*MessageHub) PublishPublicMessage added in v0.13.0

func (m *MessageHub) PublishPublicMessage(mess *Message) error

func (*MessageHub) Start added in v0.11.0

func (m *MessageHub) Start(ctx context.Context, host host.Host) error

type MessageOption

type MessageOption func(cfg *Message) error

type Option added in v0.33.0

type Option func(*MessageHub)

Option configures a MessageHub at construction time.

func WithDirectPeers added in v0.33.0

func WithDirectPeers(peers []peer.AddrInfo) Option

WithDirectPeers pins peers as gossipsub direct peers — the router holds a persistent connection to each and bypasses mesh negotiation for them, which makes pubsub delivery reliable to known/bootstrap peers even when the mesh (e.g. on a 2-node cluster) hasn't reached its target size.

Jump to

Keyboard shortcuts

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