events

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashKey

func HashKey(key string) string

HashKey hashes the input string

Types

type Database

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

Database is postgres wrapper

func NewPostgresDatabase

func NewPostgresDatabase(user string, password string, addr string, dbName string) (*Database, error)

NewPostgresDatabase creates and connects to a postgres database

func NewPostgresDatabaseFromURL added in v0.0.1

func NewPostgresDatabaseFromURL(url string) (*Database, error)

NewPostgresDatabaseFromURL creates and connects to a postgres database from a URL

func (*Database) AddEvent

func (database *Database) AddEvent(evt *Event) error

AddEvent inserts an events into the database

func (*Database) AddSymbol

func (database *Database) AddSymbol(sym *Symbol) error

AddSymbol inserts a symbol into the database

func (*Database) GetSymbols added in v0.0.2

func (database *Database) GetSymbols() ([]Symbol, error)

GetSymbols get symbols

type Event

type Event struct {
	ID               int
	Type             string                 `pg:"type:'varchar'"`
	Source           string                 `pg:"type:'varchar'"`
	Title            string                 `pg:"type:'varchar'"`
	Content          string                 `pg:"type:'text'"`
	URL              string                 `pg:"type:'varchar'"`
	ConfirmedSymbols []string               `pg:"type:'varchar',array"`
	Name             string                 `pg:"type:'varchar'"`
	Author           string                 `pg:"type:'varchar'"`
	PrevValue        string                 `pg:"type:'varchar'"`
	ExpectedValue    string                 `pg:"type:'varchar'"`
	ActualValue      string                 `pg:"type:'varchar'"`
	Impact           string                 `pg:"type:'varchar'"`
	TimeFor          string                 `pg:"type:'varchar'"`
	TimeReported     string                 `pg:"type:'varchar'"`
	Extras           map[string]interface{} `pg:"type:'json'"`
	CacheHash        string                 `pg:"type:'varchar',unique"`
	TimeLogged       string                 `pg:"type:'timestamptz'"`
	HostName         string                 `pg:"type:'varchar'"`
}

Event represents an events that occured in the world

type EventStream

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

EventStream is a stream of events

func NewEventStream

func NewEventStream(db *Database, warmUp time.Duration) *EventStream

NewEventStream creates an event stream

func (*EventStream) GetSymbols added in v0.0.2

func (es *EventStream) GetSymbols() ([]Symbol, error)

GetSymbols gets db of symbols

func (*EventStream) OnEvent

func (es *EventStream) OnEvent(evt *Event)

OnEvent handles the occurance of an event

func (*EventStream) OnEventArticleResolveBody

func (es *EventStream) OnEventArticleResolveBody(source string, title string, url string, contentResolver func(string) string)

OnEventArticleResolveBody handles an article event, if appropriate it calls contentResolver for the content of the article

type Symbol

type Symbol struct {
	ID       int
	Sym      string `pg:"type:'varchar',unique"`
	Name     string `pg:"type:'varchar'"`
	Industry string `pg:"type:'varchar'"`
	Sector   string `pg:"type:'varchar'"`
}

Jump to

Keyboard shortcuts

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