elasticsearch

package
v0.0.0-...-c86e3d9 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ArticleNotFoundError = "Article Not Found on elastic"

ArticleNotFoundError When query doesn't match to find article

View Source
var ElasticClient *elastic.Client

Functions

func MakeConnection

func MakeConnection() error

MakeConnection Establish a connection with elastic client

Types

type ElasticRepository

type ElasticRepository interface {
	SetUpIndexes() error

	IsClientReady(string) error
	CreateIndexIfNotExists(string) error

	StoreEvent(event db.Event) error
	LoadEvents(string) ([]db.Event, error)

	StoreReadmodel(db.Article) error
	UpdateReadmodel(string, db.Article) error
	GetReadmodel(string) (db.Article, error)
}

ElasticRepository Makes process on any database

type ElasticRepositoryImpl

type ElasticRepositoryImpl struct {
	Client *elastic.Client
}

func NewElasticRepository

func NewElasticRepository(elasticClient *elastic.Client) *ElasticRepositoryImpl

func (*ElasticRepositoryImpl) CreateIndexIfNotExists

func (r *ElasticRepositoryImpl) CreateIndexIfNotExists(indexName string) error

createIndexIfNotExists on elasticsearch database

func (*ElasticRepositoryImpl) GetReadmodel

func (r *ElasticRepositoryImpl) GetReadmodel(aggregateID string) (db.Article, error)

GetReadmodel returns an article from elastic pass aggregateID as param to get an article

func (*ElasticRepositoryImpl) IsClientReady

func (r *ElasticRepositoryImpl) IsClientReady(clientURL string) error

isClientReady Checks if client is ready by send packet using ping

func (*ElasticRepositoryImpl) LoadEvents

func (r *ElasticRepositoryImpl) LoadEvents(aggregateArticleID string) ([]db.Event, error)

LoadEvents returns all events from elastic

func (*ElasticRepositoryImpl) SetUpIndexes

func (r *ElasticRepositoryImpl) SetUpIndexes() error

SetUpIndexes Creates needed indexes to make POST request @see mapping.go

func (*ElasticRepositoryImpl) StoreEvent

func (r *ElasticRepositoryImpl) StoreEvent(event db.Event) error

StoreEvent stores an event for an aggregate article

func (*ElasticRepositoryImpl) StoreReadmodel

func (r *ElasticRepositoryImpl) StoreReadmodel(article database.Article) error

StoreReadmodel stores a readmodel for an aggregate article

func (*ElasticRepositoryImpl) UpdateReadmodel

func (r *ElasticRepositoryImpl) UpdateReadmodel(aggregateArticleID string,
	article database.Article) error

UpdateReadmodel stores an updated readmodel for an aggregate article

Jump to

Keyboard shortcuts

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