Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Refactor the way Elastic client is being setup #327

Closed
pkarw opened this issue Aug 21, 2019 · 2 comments
Closed

Refactor the way Elastic client is being setup #327

pkarw opened this issue Aug 21, 2019 · 2 comments
Assignees
Labels
feature request Requests for new features. Please be as specific as possible

Comments

@pkarw
Copy link
Contributor

pkarw commented Aug 21, 2019

Currently, we have have a code duplication with Elastic:

  • migrations/.common.js
  • platform/magento1/tax.js
  • platform/magento2/tax.js

we should extract the Elastic client setup code to ../../helpers/elastic.js

kind of:

	const getElasticClient = (config) => {
        const esConfig = { // as we're runing tax calculation and other data, we need a ES indexer
          host: {
            host: config.elasticsearch.host,
            port: config.elasticsearch.port,
            protocol: config.elasticsearch.protocol
          },
          apiVersion: config.elasticsearch.apiVersion,
          requestTimeout: 5000
        }
        if (config.elasticsearch.user) {
          esConfig.httpAuth = config.elasticsearch.user + ':' + config.elasticsearch.password
        }
        return new es.Client(esConfig)	
	}
@pkarw pkarw added the feature request Requests for new features. Please be as specific as possible label Aug 21, 2019
pkarw added a commit that referenced this issue Aug 21, 2019
- The `db` context object - passed to every api endpoint now has two usefull methods: `getElasticClient` and `getRedisClient` for accesing the data stores - @pkarw (#328)
- The `lib/utils` got two new methods `getStoreCode(req: Express.Request)` and `getStoreView(code: string)` for getting the current multistore context from `vue-storefront` frontend requests - @pkarw
- The way Elastic and Redis clients have been fixed and code duplication removed across the app - @pkarw (#327)
@pkarw pkarw mentioned this issue Aug 21, 2019
@pkarw pkarw closed this as completed Aug 21, 2019
@simonmaass
Copy link

@pkarw is this deployed? If i look into current deployment i see that it doesnt use the protocol...

const esConfig = { // as we're runing tax calculation and other data, we need a ES indexer
host: this._config.elasticsearch.host + ':' + this._config.elasticsearch.port,
log: 'debug',
apiVersion: this._config.elasticsearch.apiVersion,
requestTimeout: 5000
}

@pkarw
Copy link
Contributor Author

pkarw commented Nov 27, 2019

@simonmaass please do check the develop branch

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request Requests for new features. Please be as specific as possible
Projects
None yet
Development

No branches or pull requests

3 participants