I have an AngularJS app using elasticsearch . It works well, but I have a 
problem deploying to production.

I have a service that looks like this:

angular.module('components.common.elasticSearchFactory',[
])
.service('ElasticSearch', function (esFactory, Config) {
  function getHost(){
    return Config.elasticSearchHost;
  }
  return esFactory({
    host: getHost(),
    apiVersion: '1.0',
    //   pathPrefix: 'optional pathPrefix',
    secure: false
  });
});

Config.elasticSearchHost contains an environment-dependent host name 
(development, production, staging etc);

The problem is that Config is created from a database record. The 
elasticSearch service is created before the Config is retrieved. This is a 
common issue with Angular. The way I normally overcome it is with something 
like the 'getHost' function. Normally, this would run when a call is made 
to the service, by which time the Config has been resolved. 

The problem here is that getHost() is being run while esFactory is being 
configured, not when the service is being called.

Is there a way to configure the esFactory host/credentials after it has 
been instantiated?   

  

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/2ab5b030-e560-4302-8f2a-a096646881f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to