inproc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package inproc is hearth's in-process event transport: 1 bus delivers each event to the subscribers of the same process, on the goroutine that published it, and it drops an event that it has already delivered.

The bus keeps the last 1024 ids it delivered, so a relay that publishes an event again after a lost acknowledgement is harmless: the de-duplication is the 1 that the broker's JetStream does with the message's id.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

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

Bus is an in-process transport: every subscriber of the process, in the order it subscribed.

A handler runs on the goroutine that published, outside the bus's lock, so it may subscribe and publish. It must not block for long: it holds the publisher.

func New

func New() *Bus

New returns a bus with no subscriber.

func (*Bus) Publish

func (b *Bus) Publish(_ context.Context, e events.Event) error

Publish implements events.Transport: it delivers the event to each subscriber whose filter takes the event's topic, in the order they subscribed, and it skips an event whose id is among the last 1024 ids the bus delivered.

The context is not read: a subscriber of the process holds the event at once.

func (*Bus) Subscribe

func (b *Bus) Subscribe(filter string, handle func(events.Event)) (func(), error)

Subscribe subscribes 1 handler to the events that filter takes. The filter must be valid (see events.ValidFilter).

The cancel function removes the subscription, and it is safe to call twice.

Jump to

Keyboard shortcuts

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