Categorygithub.com/ONSdigital/dp-cantabular-csv-exporter
repositorypackage
1.14.0
Repository: https://github.com/onsdigital/dp-cantabular-csv-exporter.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

dp-cantabular-csv-exporter

Consumes a Kafka message (cantabular-export-start) to begin the process of retrieving the counts from Cantabular.

Getting started

Dependencies

Ensure you have vault running.

brew install vault vault server -dev

  • Setup AWS credentials. The app uses the default provider chain. When running locally this typically means they are provided by the ~/.aws/credentials file. Alternatively you can inject the credentials via environment variables as described in the configuration section.

#### Run the service

  • Run make debug

The service runs in the background consuming messages from Kafka. An example event can be created using the helper script, make produce.

Dependencies

  • Requires running…
  • No further dependencies other than those defined in go.mod

Configuration

Environment variableDefaultDescription
BIND_ADDRlocalhost:26300The host and port to bind to
GRACEFUL_SHUTDOWN_TIMEOUT5sThe graceful shutdown timeout in seconds (time.Duration format)
HEALTHCHECK_INTERVAL30sTime between self-healthchecks (time.Duration format)
HEALTHCHECK_CRITICAL_TIMEOUT90sTime to wait until an unhealthy dependent propagates its state to make this app unhealthy (time.Duration format)
DEFAULT_REQUEST_TIMEOUT10sDefault timeout for graphQL queries against Cantabular API extension and HTTP requests for the Cantabular Client only
SERVICE_AUTH_TOKENThe service token for this app
CANTABULAR_URLhttp://localhost:8491The Cantabular server URL
CANTABULAR_EXT_API_URLhttp://localhost:8492The Cantabular API extension URL
DATASET_API_URLhttp://localhost:22000The Dataset API URL
DOWNLOAD_SERVICE_URLhttp://localhost:23600The Download Service URL, only used to generate download links
CANTABULAR_HEALTHCHECK_ENABLEDfalseFlag to enable/disable healthchecks against Cantabular server and API extension
AWS_REGIONeu-west-1The AWS region to use
PUBLIC_UPLOAD_BUCKET_NAMEpublic-bucketThe name of the S3 bucket to store published csv files
PRIVATE_UPLOAD_BUCKET_NAMEprivate-bucketThe name of the S3 bucket to store un-published csv files
VAULT_ADDRhttp://localhost:8200The address of vault
VAULT_TOKEN-Use make debug to set a vault token
VAULT_PATHsecret/shared/pskThe vault path to store psks
ENCRYPTION_DISABLEDfalseFlag to enable/disable encryption for un-published csv files
STOP_CONSUMING_ON_UNHEALTHYtrueFlag to enable/disable kafka-consumer consumption depending on health status. If true, the consumer will stop consuming on 'WARNING' and 'CRITICAL' and it will start consuming on 'OK'
S3_PUBLIC_URLhttp://public-bucketThe name of the S3 public url
KAFKA_ADDRlocalhost:9092The kafka broker addresses (can be comma separated)
KAFKA_CONSUMER_MIN_BROKERS_HEALTHY1The minimum number of healthy kafka consumer brokers
KAFKA_PRODUCER_MIN_BROKERS_HEALTHY2The minimum number of healthy kafka producer brokers
KAFKA_VERSION"1.0.2"The kafka version that this service expects to connect to
KAFKA_OFFSET_OLDESTtrueStart processing Kafka messages in order from the oldest in the queue
KAFKA_NUM_WORKERS1The maximum number of parallel kafka consumers
KAFKA_MAX_BYTES2000000the maximum number of bytes per kafka message
KAFKA_GROUP_CANTABULAR_EXPORT_STARTdp-cantabular-csv-exporterThe consumer group this application to consume ImageUploaded messages
KAFKA_TOPIC_CANTABULAR_EXPORT_STARTcantabular-export-startThe name of the topic to consume messages from
KAFKA_TOPIC_CSV_CREATEDcantabular-csv-createdThe name of the topic that is produced after a CSV file has been successfully generated
KAFKA_SEC_PROTOunsetif set to TLS, kafka connections will use TLS [1]
KAFKA_SEC_CA_CERTSunsetCA cert chain for the server cert [1]
KAFKA_SEC_CLIENT_KEYunsetPEM for the client key [1]
KAFKA_SEC_CLIENT_CERTunsetPEM for the client certificate [1]
KAFKA_SEC_SKIP_VERIFYfalseignores server certificate issues if true [1]
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317Endpoint for OpenTelemetry service
OTEL_SERVICE_NAMEdp-cantabular-csv-exporterLabel of service for OpenTelemetry service
OTEL_BATCH_TIMEOUT5sTimeout for OpenTelemetry

Notes:

1. <a name="notes_1">For more info, see the [kafka TLS examples documentation](https://github.com/ONSdigital/dp-kafka/tree/main/examples#tls)</a>

Healthcheck

The /health endpoint returns the current status of the service. Dependent services are health checked on an interval defined by the HEALTHCHECK_INTERVAL environment variable.

On a development machine a request to the health check endpoint can be made by:

curl localhost:8125/health

Contributing

See CONTRIBUTING for details.

License

Copyright © 2022, Office for National Statistics (https://www.ons.gov.uk)

Released under MIT license, see LICENSE for details