event

package
v0.1.0-alpha12 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package event provides types used to read events from an event bus.

Package event provides types for communicating with various event buses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReadFunc

type ReadFunc func(ctx context.Context, message json.RawMessage) error

The ReadFunc type is a function that is invoked per-event when using Reader.Read.

type Reader

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

The Reader type is used to read individual events from an event stream.

func NewReader

func NewReader(ctx context.Context, url string) (*Reader, error)

NewReader returns a new instance of the Reader type, configured to use the event bus described in the URL string.

func (*Reader) Close

func (r *Reader) Close() error

Close the connection to the event bus.

func (*Reader) Read

func (r *Reader) Read(ctx context.Context, fn ReadFunc) error

Read events from the bus, invoking the ReadFunc for each. This method blocks until the context is cancelled or ReadFunc returns a non-nil error. If the ReadFunc returns a non-nil error, a NACK will be performed on the message where possible before returning. Otherwise, an ACK is performed and the next event is requested.

type Writer

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

The Writer type is used to publish JSON-encoded messages onto an event bus.

func NewWriter

func NewWriter(ctx context.Context, url string) (*Writer, error)

NewWriter returns a new instance of the Writer type that can be used to publish JSON-encoded messages onto an event bus. The event bus used is expressed via the url string.

func (*Writer) Close

func (w *Writer) Close() error

Close the connection to the event bus.

func (*Writer) Write

func (w *Writer) Write(ctx context.Context, message json.RawMessage) error

Write a JSON-encoded message onto the bus.

Jump to

Keyboard shortcuts

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