Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrFailedToPingElastic = errors.New("failed to ping elastic cluster")
)
Functions ¶
This section is empty.
Types ¶
type Elastic ¶
type Elastic struct { Config ElasticConfig // contains filtered or unexported fields }
func NewElastic ¶
func NewElastic(config ElasticConfig) Elastic
func (*Elastic) StartClient ¶
func (*Elastic) StartTypedClient ¶
type ElasticConfig ¶
type News ¶
type News struct { Id string `json:"id,omitempty"` Headline string `json:"headline"` Body string `json:"body,omitempty"` Tickers []string `json:"tickers,omitempty"` Source string `json:"source"` PublicationTime time.Time `json:"publicationTime"` ReceivedTime time.Time `json:"receivedTime"` CreationTime time.Time `json:"creationTime"` // Override by insert function // CategoryCodes represents a code which varies from provider to provider and represents a specific topic such as // acquisitions, mergers, etc. CategoryCodes []string `json:"categoryCodes"` // Ciks only applies to SEC Ciks []int `json:"ciks,omitempty"` // Link only applies to SEC Link string `json:"link,omitempty"` }
News describes a document that can be inserted to ElasticSearch. Each field is commented with the sources it applies to.
func (*News) UnmarshalJSON ¶ added in v0.8.15
type NewsRepository ¶
type NewsRepository struct { Index string // Defaults to "news" // contains filtered or unexported fields }
func NewNewsRepository ¶
func NewNewsRepository(elastic Elastic) (NewsRepository, error)
NewNewsRepository creates a NewsRepository, if the context is a test, an index other than "news" must be passed otherwise it will fail.
func (NewsRepository) Insert ¶
func (b NewsRepository) Insert(news *News) error
func (NewsRepository) InsertBatch ¶
func (b NewsRepository) InsertBatch(news []*News, insertedCallback func(totalIndexed int, lastIndex int)) error
InsertBatch inserts a batch of news, if the batch is too big, it is uploaded in sub-batches. news must be ordered from [oldest... newest]. The insertedCallback is called after a sub-batch is inserted it sends as arguments the total amount of news in the sub-batch and the batch index of the last item in the sub-batch.
type Repository ¶
Click to show internal directories.
Click to hide internal directories.