elasticsearch

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
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) GetOrder

func (repository *OrderRepository) GetOrder(ctx context.Context, orderID string) (*Document, error)

GetOrder is for getting an order

func (*OrderRepository) GetOrderLine

func (repository *OrderRepository) GetOrderLine(ctx context.Context, orderLineID string) (*Document, error)

GetOrderLine is for getting an order

func (*OrderRepository) PersistOrder

func (repository *OrderRepository) PersistOrder(ctx context.Context, order *models.Order) error

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

Jump to

Keyboard shortcuts

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