eventbus

package
v1.0.60 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Provide simplistic application-wide message bus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call added in v1.0.58

func Call[M any, R any](address string, msg *M) (*R, error)

Call sends a message to the address specified as an argument, and waits for the response.

func CallWithContext added in v1.0.59

func CallWithContext[M any, R any](address string, msg *M, ctx context.Context) (*R, error)

CallWithContext sends a message to the address specified as an argument, and waits for the response.

func Consume

func Consume[M any](address string, handler func(*M, CallContext)) func()

Consume registers a consumer for messages sent to the address specified as an argument. Handler is called for each published message inside its own panic-safe goroutine.

func Publish

func Publish[M any](address string, msg *M)

Publish sends a message to the address specified as an argument.

Types

type CallContext added in v1.0.58

type CallContext interface {
	// Reply sends a reply back to caller.
	Reply(reply any)
}

CallContext is a context passed to an event bus handler. It allows consumers to send replies.

Jump to

Keyboard shortcuts

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