event

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEventNotFound = errors.New("event record not found")
)

Functions

This section is empty.

Types

type EventType

type EventType uint32
const (
	UnknownEvent EventType = iota
	AccountCreated
	WelcomeBonusClaimed
	InPersonGrab
	RemoteSend
	MicroPayment
	Withdrawal
)

type Record

type Record struct {
	Id uint64

	// A common ID generally agreed upon. For example, a money movement flow using
	// multiple intents may want to standardize on which intent ID is used to add
	// additional metadata as it becomes available.
	EventId   string
	EventType EventType

	// Involved accounts
	SourceCodeAccount      string
	DestinationCodeAccount *string
	ExternalTokenAccount   *string

	// Involved identities
	SourceIdentity      string
	DestinationIdentity *string

	// Involved IP addresses, and associated metadata
	//
	// todo: Requires MaxMind data set. IP metadata be missing until we do.
	// todo: May add additional "interesting" IP metadata after reviewing MaxMind data set.
	SourceClientIp           *string
	SourceClientCity         *string
	SourceClientCountry      *string
	DestinationClientIp      *string
	DestinationClientCity    *string
	DestinationClientCountry *string

	UsdValue *float64

	// Could be a good way to trigger human reviews, or automated ban processes,
	// for example. Initially, this will always be zero until we learn more about
	// good rulesets.
	SpamConfidence float64 // [0, 1]

	CreatedAt time.Time
}

func (*Record) Clone

func (r *Record) Clone() Record

func (*Record) CopyTo

func (r *Record) CopyTo(dst *Record)

func (*Record) Validate

func (r *Record) Validate() error

todo: Per-event type validation than just the basic stuff defined here

type Store

type Store interface {
	// Save creates or updates an event record. For updates, only fields that can
	// be reasonably changed or provided at a later time are supported.
	Save(ctx context.Context, record *Record) error

	// Get gets an event record by its event ID
	Get(ctx context.Context, id string) (*Record, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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