Help us shape the future of Go! Take the 2026 Go Developer Survey

pubsub

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Copyright (C) 2025 l3montree GmbH

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker interface {
	Publish(ctx context.Context, message Message) error
	Subscribe(topic Channel) (<-chan map[string]interface{}, error)
}

func BrokerFactory

func BrokerFactory() (Broker, error)

type Channel

type Channel string
const (
	PolicyChange Channel = "policyChange"
)

type Message

type Message interface {
	GetChannel() Channel
	GetPayload() map[string]interface{}
}

type PostgreSQLBroker

type PostgreSQLBroker struct {
	ID string // Unique identifier for the broker instance
	// contains filtered or unexported fields
}

PostgreSQLBroker implements the Broker interface using PostgreSQL LISTEN/NOTIFY

func NewPostgreSQLBroker

func NewPostgreSQLBroker(user, password, host, port, dbname string) (*PostgreSQLBroker, error)

NewPostgreSQLBroker creates a new PostgreSQL broker

func (*PostgreSQLBroker) Close

func (b *PostgreSQLBroker) Close() error

Close stops the broker and cleans up resources

func (*PostgreSQLBroker) GetActiveTopics

func (b *PostgreSQLBroker) GetActiveTopics() []Channel

GetActiveTopics returns a list of topics currently being listened to

func (*PostgreSQLBroker) IsHealthy

func (b *PostgreSQLBroker) IsHealthy() bool

IsHealthy checks if the broker is functioning properly

func (*PostgreSQLBroker) Publish

func (b *PostgreSQLBroker) Publish(ctx context.Context, message Message) error

Publish implements the Broker interface

func (*PostgreSQLBroker) SetShouldReceiveOwnMessages

func (b *PostgreSQLBroker) SetShouldReceiveOwnMessages(should bool)

func (*PostgreSQLBroker) Subscribe

func (b *PostgreSQLBroker) Subscribe(topic Channel) (<-chan map[string]interface{}, error)

Subscribe implements the Broker interface

type PostgreSQLMessage

type PostgreSQLMessage struct {
	ID        string                 `json:"id"`
	Channel   Channel                `json:"topic"`
	Payload   map[string]interface{} `json:"payload"`
	Timestamp time.Time              `json:"timestamp"`
	SenderID  string                 `json:"sender_id,omitempty"` // Optional field for sender ID
}

func (PostgreSQLMessage) GetChannel

func (m PostgreSQLMessage) GetChannel() Channel

func (PostgreSQLMessage) GetPayload

func (m PostgreSQLMessage) GetPayload() map[string]interface{}

type SimpleMessage

type SimpleMessage struct {
	Channel Channel
	Payload map[string]interface{}
}

func NewSimpleMessage

func NewSimpleMessage(channel Channel, payload map[string]interface{}) *SimpleMessage

NewSimpleMessage creates a new SimpleMessage instance.

func (SimpleMessage) GetChannel

func (m SimpleMessage) GetChannel() Channel

func (SimpleMessage) GetPayload

func (m SimpleMessage) GetPayload() map[string]interface{}

Jump to

Keyboard shortcuts

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