Documentation ¶
Index ¶
- Constants
- type Document
- type EsConnector
- func (connector *EsConnector) GetDocumentByIndexAndID(ctx context.Context, index string, documentID string) (*Document, error)
- func (connector *EsConnector) NewDocument(ctx context.Context, index string, document *Document) error
- func (connector *EsConnector) NewIndex(ctx context.Context, index string) error
- func (connector *EsConnector) UpdateDocument(ctx context.Context, index string, document *Document) (*elastic.UpdateResponse, error)
- type EsService
- type OrderRepository
- func (repository *OrderRepository) AddEventInES(ctx context.Context, event *eventsourcing.Event) error
- func (repository *OrderRepository) GetOrder(ctx context.Context, orderID string) (*Document, error)
- func (repository *OrderRepository) GetOrderLine(ctx context.Context, orderLineID string) (*Document, error)
- func (repository *OrderRepository) PersistOrder(ctx context.Context, order *models.Order) error
- func (repository *OrderRepository) PersistOrderLine(ctx context.Context, orderLine *models.OrderLine) error
- func (repository *OrderRepository) UpdateOrderLine(ctx context.Context, orderLine *models.OrderLine) error
Constants ¶
const ( OrderIndex = "index_order" OrderEventIndex = "index_order_event" OrderLineIndex = "index_order_line" )
Indexes for ES
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct { ID string Body interface{} }
Document represents an Elastic Search(ES) document
type EsConnector ¶
type EsConnector struct {
// contains filtered or unexported fields
}
EsConnector encapsulates ES client for all es methods
func NewEsConnector ¶
func NewEsConnector(client *elastic.Client) *EsConnector
NewEsConnector return a new ESConnector
func (*EsConnector) GetDocumentByIndexAndID ¶
func (connector *EsConnector) GetDocumentByIndexAndID(ctx context.Context, index string, documentID string) (*Document, error)
GetDocumentByIndexAndID retrieves a document by its index and its ID from ES
func (*EsConnector) NewDocument ¶
func (connector *EsConnector) NewDocument(ctx context.Context, index string, document *Document) error
NewDocument creates a new document in ES (by Index)
func (*EsConnector) NewIndex ¶
func (connector *EsConnector) NewIndex(ctx context.Context, index string) error
NewIndex creates a new index in ES.
func (*EsConnector) UpdateDocument ¶
func (connector *EsConnector) UpdateDocument(ctx context.Context, index string, document *Document) (*elastic.UpdateResponse, error)
UpdateDocument updates an ES document
type EsService ¶
type EsService interface { NewIndex(context.Context, string) error NewDocument(context.Context, string, *Document) error GetDocumentByIndexAndID(context.Context, string, string) (*Document, error) }
EsService is an interface for all ES methods
type OrderRepository ¶
type OrderRepository struct {
EsConnector *EsConnector
}
OrderRepository encapsulates the ESConnector for all repository methods
func NewOrderRepository ¶
func NewOrderRepository(client *elastic.Client) *OrderRepository
NewOrderRepository return a new OrderRepository
func (*OrderRepository) AddEventInES ¶
func (repository *OrderRepository) AddEventInES(ctx context.Context, event *eventsourcing.Event) error
AddEventInES Adds an event is ES
func (*OrderRepository) GetOrderLine ¶
func (repository *OrderRepository) GetOrderLine(ctx context.Context, orderLineID string) (*Document, error)
GetOrderLine is for getting an order
func (*OrderRepository) PersistOrder ¶
PersistOrder persists the order as is in elastic search
func (*OrderRepository) PersistOrderLine ¶
func (repository *OrderRepository) PersistOrderLine(ctx context.Context, orderLine *models.OrderLine) error
PersistOrderLine persists a fixed state of orderLine
func (*OrderRepository) UpdateOrderLine ¶
func (repository *OrderRepository) UpdateOrderLine(ctx context.Context, orderLine *models.OrderLine) error
UpdateOrderLine updates an order line in ES