events

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRoutes

func AddRoutes(logger log.Logger, r *mux.Router, eventRepo Repository)

Types

type Event

type Event struct {
	ID      EventID   `json:"id"`
	Topic   string    `json:"topic"`
	Message string    `json:"message"`
	Type    EventType `json:"type"`

	Metadata map[string]string `json:"metadata"`
}

type EventID

type EventID string

type EventType

type EventType string
const (
	// TODO(adam): more EventType values?
	// ReceiverEvent   EventType = "Receiver"
	// DepositoryEvent EventType = "Depository"
	// OriginatorEvent EventType = "Originator"
	TransferEvent EventType = "Transfer"
)

type Repository

type Repository interface {
	GetEvent(eventID EventID, userID id.User) (*Event, error)
	GetUserEvents(userID id.User) ([]*Event, error)

	GetUserEventsByMetadata(userID id.User, metadata map[string]string) ([]*Event, error)

	WriteEvent(userID id.User, event *Event) error
}

type SQLRepository

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

func NewRepo

func NewRepo(logger log.Logger, db *sql.DB) *SQLRepository

func (*SQLRepository) Close

func (r *SQLRepository) Close() error

func (*SQLRepository) GetEvent

func (r *SQLRepository) GetEvent(eventID EventID, userID id.User) (*Event, error)

func (*SQLRepository) GetUserEvents

func (r *SQLRepository) GetUserEvents(userID id.User) ([]*Event, error)

func (*SQLRepository) GetUserEventsByMetadata

func (r *SQLRepository) GetUserEventsByMetadata(userID id.User, metadata map[string]string) ([]*Event, error)

func (*SQLRepository) WriteEvent

func (r *SQLRepository) WriteEvent(userID id.User, event *Event) error

type TestRepository

type TestRepository struct {
	Err   error
	Event *Event
}

func (*TestRepository) GetEvent

func (r *TestRepository) GetEvent(eventID EventID, userID id.User) (*Event, error)

func (*TestRepository) GetUserEvents

func (r *TestRepository) GetUserEvents(userID id.User) ([]*Event, error)

func (*TestRepository) GetUserEventsByMetadata

func (r *TestRepository) GetUserEventsByMetadata(userID id.User, metadata map[string]string) ([]*Event, error)

func (*TestRepository) WriteEvent

func (r *TestRepository) WriteEvent(userID id.User, event *Event) error

Jump to

Keyboard shortcuts

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