company

package
v0.0.0-...-7dbc1ad Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCache = errors.New("Unable to handle Cache Request")

Functions

func NewHTTPServer

func NewHTTPServer(ctx context.Context, endpoints Endpoints) http.Handler

Types

type Cache

type Cache interface {
	GetCompanyBySymbol(ctx context.Context, symbol string) (Company, error)
	SetCompany(ctx context.Context, company Company) error
}

func NewCache

func NewCache(db *gorm.DB, logger log.Logger) Cache

type Company

type Company struct {
	gorm.Model
	Symbol string `gorm:"unique"`
	// Name of the company
	CompanyName string
	// Number of employees
	Employees   uint
	Exchange    string
	Industry    string
	Website     string
	Description string
	CEO         string
	// Name of the security
	SecurityName string
	// refers to the common issue type of the stock.
	// ad – American Depository Receipt (ADR’s)
	// re – Real Estate Investment Trust (REIT’s)
	// ce – Closed end fund (Stock and Bond Fund)
	// si – Secondary Issue
	// lp – Limited Partnerships
	// cs – Common Stock
	// et – Exchange Traded Fund (ETF)
	// wt – Warrant
	// rt – Right
	// (blank) – Not Available, i.e., Note, or (non-filing) Closed Ended Funds
	// ut - Unit
	// temp - Temporary
	IssueType string
	Sector    string
	//	Primary SIC Code for the symbol (if available)
	PrimarySicCode uint
	//an array of strings used to classify the company.
	// Tags []Tag `gorm:"many2many:company_tags;"`
	// street address of the company if available
	Address string
	//street address of the company if available
	Address2 string
	//	state of the company if available
	State string
	//	city of the company if available
	City string
	//	zip of the company if available
	Zip string
	//	country of the company if available
	Country string
	//	phone number of the company if available
	Phone string
}

type Endpoints

type Endpoints struct {
	GetCompanyBySymbol endpoint.Endpoint
}

func NewEndpoints

func NewEndpoints(s Service) Endpoints

type GetCompanyBySymbolRequest

type GetCompanyBySymbolRequest struct {
	Symbol string `json:"symbol"`
}

type GetCompanyBySymbolResponse

type GetCompanyBySymbolResponse struct {
	Company Company `json:"company"`
}

type IEX

type IEX interface {
	GetCompanyBySymbol(ctx context.Context, symbol string) (Company, error)
}

func NewIEX

func NewIEX(logger log.Logger, token string) IEX

type LoggingMiddleware

type LoggingMiddleware struct {
	Logger log.Logger
	Next   Service
}

func (LoggingMiddleware) GetCompanyBySymbol

func (mw LoggingMiddleware) GetCompanyBySymbol(ctx context.Context, symbol string) (company Company, err error)

type MetricsMiddleware

type MetricsMiddleware struct {
	RequestCount   metrics.Counter
	RequestLatency metrics.Histogram
	Next           Service
}

func (MetricsMiddleware) GetCompanyBySymbol

func (mw MetricsMiddleware) GetCompanyBySymbol(ctx context.Context, symbol string) (Company, error)

type Service

type Service interface {
	// GetCompanyBySymbol returns all public data about a company and their stock.
	GetCompanyBySymbol(ctx context.Context, symbol string) (Company, error)
}

func NewService

func NewService(cache Cache, iex IEX, logger log.Logger) Service

Jump to

Keyboard shortcuts

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