Skip to content

Commit

Permalink
added app name param
Browse files Browse the repository at this point in the history
  • Loading branch information
peterschubert committed Apr 21, 2017
1 parent 5e92f90 commit 8f19921
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Download the source code, dependencies and test dependencies:
Options:

--app-system-code="content-rw-elasticsearch" System Code of the application ($APP_SYSTEM_CODE)
--app-name="Content RW Elasticsearch" Application name ($APP_NAME)
--port="8080" Port to listen on ($APP_PORT)
--aws-access-key="" AWS ACCES KEY ($AWS_ACCESS_KEY_ID)
--aws-secret-access-key="" AWS SECRET ACCES KEY ($AWS_SECRET_ACCESS_KEY)
Expand All @@ -39,7 +40,6 @@ Options:
--kafka-consumer-group="default-consumer-group" Group used to read the messages from the queue ($KAFKA_CONSUMER_GROUP)
--kafka-topic="CombinedPostPublicationEvents" The topic to read the meassages from ($KAFKA_TOPIC)
--kafka-header="kafka" The header identifying the queue to read the messages from ($KAFKA_HEADER)
--kafka-concurrent-processing=false Whether the consumer uses concurrent processing for the messages ($KAFKA_CONCURRENT_PROCESSING)

3. Test:

Expand Down
12 changes: 6 additions & 6 deletions content_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ func waitForSignal() {
<-ch
}

func (indexer *contentIndexer) start(appSystemCode string, indexName string, port string, accessConfig esAccessConfig, queueConfig consumer.QueueConfig) {
func (indexer *contentIndexer) start(appSystemCode string, appName string, indexName string, port string, accessConfig esAccessConfig, queueConfig consumer.QueueConfig) {
channel := make(chan esClientI)
go func() {
defer close(channel)
for {
ec, err := newAmazonClient(accessConfig)
if err == nil {
log.Infof("connected to ElasticSearch")
log.Infof("connected to Elasticsearch")
channel <- ec
return
}
log.Errorf("could not connect to ElasticSearch: %s", err.Error())
log.Errorf("could not connect to Elasticsearch: %s", err.Error())
time.Sleep(time.Minute)
}
}()
Expand All @@ -74,19 +74,19 @@ func (indexer *contentIndexer) start(appSystemCode string, indexName string, por
}()

go func() {
indexer.serveAdminEndpoints(appSystemCode, port, queueConfig)
indexer.serveAdminEndpoints(appSystemCode, appName, port, queueConfig)
}()
}

func (indexer *contentIndexer) serveAdminEndpoints(appSystemCode string, port string, queueConfig consumer.QueueConfig) {
func (indexer *contentIndexer) serveAdminEndpoints(appSystemCode string, appName string, port string, queueConfig consumer.QueueConfig) {
healthService := newHealthService(indexer.esServiceInstance, queueConfig.Topic, queueConfig.Addrs[0])
var monitoringRouter http.Handler = mux.NewRouter()
monitoringRouter = httphandlers.TransactionAwareRequestLoggingHandler(log.StandardLogger(), monitoringRouter)
monitoringRouter = httphandlers.HTTPMetricsHandler(metrics.DefaultRegistry, monitoringRouter)

serveMux := http.NewServeMux()

hc := health.HealthCheck{SystemCode: appSystemCode, Name: appSystemCode, Description: "Content Read Writer for Elasticsearch", Checks: healthService.checks}
hc := health.HealthCheck{SystemCode: appSystemCode, Name: appName, Description: "Content Read Writer for Elasticsearch", Checks: healthService.checks}
serveMux.HandleFunc(healthPath, health.Handler(hc))
serveMux.HandleFunc(healthDetailsPath, healthService.HealthDetails)
serveMux.HandleFunc(status.GTGPath, status.NewGoodToGoHandler(healthService.gtgCheck))
Expand Down
4 changes: 2 additions & 2 deletions content_indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestStartClient(t *testing.T) {

indexer := contentIndexer{}

indexer.start("app", "index", "1985", accessConfig, queueConfig)
indexer.start("app", "name", "index", "1985", accessConfig, queueConfig)

time.Sleep(100 * time.Millisecond)

Expand Down Expand Up @@ -166,7 +166,7 @@ func TestStartClientError(t *testing.T) {

indexer := contentIndexer{}

indexer.start("app", "index", "1984", accessConfig, queueConfig)
indexer.start("app", "name", "index", "1984", accessConfig, queueConfig)

time.Sleep(100 * time.Millisecond)

Expand Down
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func main() {
app := cli.App("content-rw-es", "Service for loading contents into elasticsearch")
app := cli.App("content-rw-elasticsearch", "Service for loading contents into elasticsearch")

appSystemCode := app.String(cli.StringOpt{
Name: "app-system-code",
Expand All @@ -17,6 +17,13 @@ func main() {
EnvVar: "APP_SYSTEM_CODE",
})

appName := app.String(cli.StringOpt{
Name: "app-name",
Value: "Content RW Elasticsearch",
Desc: "Application name",
EnvVar: "APP_NAME",
})

port := app.String(cli.StringOpt{
Name: "port",
Value: "8080",
Expand Down Expand Up @@ -96,7 +103,7 @@ func main() {

app.Action = func() {
indexer := contentIndexer{}
indexer.start(*appSystemCode, *indexName, *port, accessConfig, queueConfig)
indexer.start(*appSystemCode, *appName, *indexName, *port, accessConfig, queueConfig)
waitForSignal()
}
err := app.Run(os.Args)
Expand Down

0 comments on commit 8f19921

Please sign in to comment.