Documentation
¶
Index ¶
Constants ¶
View Source
const ModuleName = "elasticsearch"
ModuleName is the module name.
Variables ¶
View Source
var FxElasticsearchModule = fx.Module( ModuleName, fx.Provide( fx.Annotate(NewDefaultElasticsearchClientFactory, fx.As(new(ElasticsearchClientFactory))), NewFxElasticsearchClient, ), )
FxElasticsearchModule is the Fx elasticsearch module.
Functions ¶
func NewFxElasticsearchClient ¶
func NewFxElasticsearchClient(p FxElasticsearchClientParam) (*elasticsearch.Client, error)
NewFxElasticsearchClient returns a elasticsearch.Client. In test environment, it returns a default mock client with basic functionality. In production, it returns a real client connected to Elasticsearch.
For advanced testing scenarios, use NewMockESClient, NewMockESClientWithSingleResponse, or NewMockESClientWithError from this package to create custom mock clients.
Types ¶
type DefaultElasticsearchClientFactory ¶
type DefaultElasticsearchClientFactory struct {
// contains filtered or unexported fields
}
func NewDefaultElasticsearchClientFactory ¶
func NewDefaultElasticsearchClientFactory(config *config.Config) *DefaultElasticsearchClientFactory
func (*DefaultElasticsearchClientFactory) Create ¶
func (f *DefaultElasticsearchClientFactory) Create() (*elasticsearch.Client, error)
type ElasticsearchClientFactory ¶
type ElasticsearchClientFactory interface {
Create() (*elasticsearch.Client, error)
}
type FxElasticsearchClientParam ¶
type FxElasticsearchClientParam struct { fx.In Config *config.Config Factory ElasticsearchClientFactory }
FxElasticsearchClientParam allows injection of the required dependencies in [NewElasticsearchClient].
Click to show internal directories.
Click to hide internal directories.