events

package
v0.0.0-...-d1151a3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHandler

func RegisterHandler(r *gin.Engine, s Service)

RegisterHandler sets up the routing of the HTTP handlers.

Types

type CreateEventRequest

type CreateEventRequest struct {
	UserID string    `json:"user_id" binding:"required,uuid4"`
	Type   EventType `json:"type" binding:"required"`
}

CreateEventRequest represents an incoming event

func (*CreateEventRequest) Validate

func (m *CreateEventRequest) Validate() error

Validate validates the CreateEventRequest fields.

type Event

type Event struct {
	UserID    string    `json:"user_id"`
	Type      EventType `json:"type"`
	CreatedAt time.Time `json:"created_at"`
}

Event represents an action performed by user

type EventType

type EventType string

EventType represents type of event performed

const (
	ClickEvent EventType = "CLICK"
)

Valid event types

type Repository

type Repository interface {
	Create(ctx context.Context, event *Event) error
}

Repository encapsulates data access logic from and to ES.

func NewRepository

func NewRepository(es *elastic.Client) Repository

NewRepository creates a new event repository

type Service

type Service interface {
	Create(ctx context.Context, req *CreateEventRequest) error
}

Service encapsulates usecase logic for events

func NewService

func NewService(r Repository) Service

NewService creates a new event service.

Jump to

Keyboard shortcuts

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