emitter

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 6 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

Index

Constants

View Source
const (
	EventUserCreated            = "user.created"
	EventUserUpdated            = "user.updated"
	EventUserDeleted            = "user.deleted"
	EventLoginSuccess           = "auth.login.success"
	EventLoginFailed            = "auth.login.failed"
	EventPasswordReset          = "auth.password.reset"
	EventPasswordResetInitiated = "auth.password.reset.initiated"
	EventPasswordChanged        = "auth.password.changed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthEventData

type AuthEventData struct {
	UserID      string    `json:"user_id"`
	Email       string    `json:"email"`
	PhoneNumber string    `json:"phoneNumber"`
	ResetToken  string    `json:"reset_token,omitempty"`
	IP          string    `json:"ip"`
	UserAgent   string    `json:"user_agent"`
	Timestamp   time.Time `json:"timestamp"`
	EventType   string    `json:"event_type"` // Type of auth event (login, password reset, etc.)
	Success     bool      `json:"success"`    // For events that can succeed/fail
}

type EventEmitter

type EventEmitter interface {
	EmitAuthEvent(ctx context.Context, user interfaces.User, data AuthEventData) error
	EmitLoginEvent(ctx context.Context, user interfaces.User, ip, userAgent string, success bool) error
	EmitPasswordEvent(ctx context.Context, user interfaces.User, ip, userAgent string, eventType string) error
	EmitUserEvent(ctx context.Context, user interfaces.User, eventType string) error
	EmitPasswordResetEvent(ctx context.Context, user interfaces.User) error
	EmitPasswordResetInitiatedEvent(ctx context.Context, user interfaces.User, resetToken string) error
	EmitPasswordChangedEvent(ctx context.Context, user interfaces.User) error
}

func NewEventEmitter

func NewEventEmitter(eventBus event.Bus, topic string) EventEmitter

NewEventEmitter binds the emitter to the given Kafka topic (the auth module's config.EventsTopic). An empty topic makes EmitAuthEvent a silent no-op instead of publishing to a topic named after the event type itself (e.g. "auth.login.success"), which no broker provisions and fails with "topic or partition does not exist".

type LoginEventData

type LoginEventData struct {
	UserID    string    `json:"userId"`
	Email     string    `json:"email"`
	IP        string    `json:"ip"`
	UserAgent string    `json:"userAgent"`
	Timestamp time.Time `json:"timestamp"`
}

type LoginFailedEventData

type LoginFailedEventData struct {
	UserID    string    `json:"user_id"`
	Email     string    `json:"email"`
	IP        string    `json:"ip"`
	UserAgent string    `json:"user_agent"`
	Timestamp time.Time `json:"timestamp"`
}

type UserEventData

type UserEventData struct {
	ID        string    `json:"id"`
	Email     string    `json:"email"`
	CreatedAt time.Time `json:"createdAt"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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