changepub

package
v0.310.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package changepub publishes write-change events on the IPC PUB socket after every successful DB write on the primary instance, allowing secondaries to invalidate caches and refresh views without polling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MethodToTopic

func MethodToTopic(method string) string

MethodToTopic maps a db.write method name to the corresponding PUB topic. Returns an empty string for methods that do not warrant a change event (e.g. read-only helpers or internal bookkeeping that secondaries need not see).

Types

type BusPublisher

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

BusPublisher publishes write-change events through an ipc.Bus.

func NewBusPublisher

func NewBusPublisher(publishFn PublishFunc, instanceID, path string) *BusPublisher

NewBusPublisher creates a BusPublisher that wraps the given bus publish function.

func (*BusPublisher) Publish

func (p *BusPublisher) Publish(_ context.Context, topic string, payload any) error

Publish wraps payload in a WriteChange envelope and sends it on the bus. The context parameter is reserved for future cancellation support.

type NoopPublisher

type NoopPublisher struct{}

NoopPublisher discards all events — used when no bus is available.

func (NoopPublisher) Publish

func (NoopPublisher) Publish(_ context.Context, _ string, _ any) error

Publish is a no-op that always succeeds.

type PublishFunc

type PublishFunc func(topic string, payload any) error

PublishFunc is the signature of the bus publish function.

type Publisher

type Publisher interface {
	Publish(ctx context.Context, topic string, payload any) error
}

Publisher sends write-change events on the IPC bus after every DB write.

type WriteChange

type WriteChange struct {
	InstanceID string          `json:"instance_id"`
	Path       string          `json:"path"`
	Topic      string          `json:"topic"`
	Payload    json.RawMessage `json:"payload"`
	Timestamp  string          `json:"timestamp"` // RFC3339
}

WriteChange is the standard envelope for write-change events.

Jump to

Keyboard shortcuts

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