Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 rethinkdb. Each field is commented with the sources it applies to.
type NewsRepository ¶
type NewsRepository struct { Index string // Defaults to "news" // contains filtered or unexported fields }
func NewNewsRepository ¶
func NewNewsRepository(elastic Elastic, sequenceIndex ...string) (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 ¶
type Sequence ¶
type Sequence struct {
// contains filtered or unexported fields
}
Sequence helps retrieve unique and sequential ids from ElasticSearch using the method: https://blogs.perl.org/users/clinton_gormley/2011/10/elasticsearchsequence---a-blazing-fast-ticket-server.html
func NewSequence ¶
NewSequence creates a Sequence. The index argument is the index for which a sequence will be generated.
func (*Sequence) GenerateUniqueIds ¶
GenerateUniqueIds requests unique ids to Sequence.sequenceIndex, the ids are generated for s.index