events

package
v0.0.0-...-6343e97 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package events represents a stub for producing events to a Kafka topic, a real implementation would contain logic for retrying failed events etc

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventType

type EventType string

EventType represents the type of event that occurred.

const (
	// EventTypeUserCreated is triggered after a user has been successfully created.
	EventTypeUserCreated EventType = "user_created"
	// EventTypeUserUpdated is triggered after a user has been successfully updated.
	EventTypeUserUpdated EventType = "user_updated"
	// EventTypeUserDeleted is triggered after a user has been successfully deleted.
	EventTypeUserDeleted EventType = "user_deleted"
)

type Events

type Events struct{}

Events represents an implementation that can produce events.

func New

func New() *Events

New will instantiate a new instance of Events.

func (*Events) Produce

func (e *Events) Produce(ctx context.Context, topic Topic, payload interface{})

Produce will produce an event on the given topic using the supplied payload.

type Topic

type Topic string

Topic represents a topic in Kafka.

const (
	// TopicUsers represents a topic for user entity events such as CRUD events.
	TopicUsers Topic = "users"
)

type UserEvent

type UserEvent struct {
	EventType EventType   `json:"event_type"`
	ID        string      `json:"id"`
	User      *model.User `json:"user"`
}

UserEvent represents an event that occurs on a user entity.

Jump to

Keyboard shortcuts

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