Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/onsdigital/dp-search-reindex-api

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/onsdigital/dp-search-reindex-api

  • v0.28.0
  • Source
  • Go
  • Socket score

Version published
Created
Source

dp-search-reindex-api

Provides detail about search reindex jobs and enables creation of a new job and triggering the reindex of data for Search Service. See search service architecture docs here

Getting started

Run make help to see full list of make targets, otherwise read the following:

  • Set up dependencies locally as follows:

In dp-compose repo run docker-compose up -d to run MongoDB on port 27017.

NB. The above command will also run Site Wide ElasticSearch, on port 11200, which is required by the Search API.

Run vault server -dev (this is required by Zebedee)

In the zebedee repo run ./run.sh to run Zebedee

In the dp-search-api repo set the ELASTIC_SEARCH_URL environment variable as follows (to use the Site Wide ElasticSearch):

export ELASTIC_SEARCH_URL="http://localhost:11200"

Also in the dp-search-api repo run make debug

Make sure that you have a valid local SERVICE_AUTH_TOKEN environment variable value; if not then set one up by following these instructions: https://github.com/ONSdigital/zebedee

  • Then in the dp-search-reindex-api repo run make debug

Dependencies

  • Requires MongoDB running on port 27017
  • Requires Kafka running on port 9092
  • Requires Zebedee running on port 8082
  • Requires Search API running on port 23900
  • No further dependencies other than those defined in go.mod

Configuration

Environment variableDefaultDescription
BIND_ADDRlocalhost:25700The host and port to bind to (The http:// scheme prefix is added programmatically)
DEFAULT_LIMIT20The default number of items to be returned from a list endpoint
DEFAULT_MAXIMUM_LIMIT1000The maximum number of items to be returned in any list endpoint (to prevent performance issues)
DEFAULT_OFFSET0The number of items into the full list (i.e. the 0-based index) that a particular response is starting at
GRACEFUL_SHUTDOWN_TIMEOUT20sThe graceful shutdown timeout in seconds (time.Duration format)
HEALTHCHECK_CRITICAL_TIMEOUT90sTime to wait until an unhealthy dependent propagates its state to make this app unhealthy (time.Duration format)
HEALTHCHECK_INTERVAL30sTime between self-healthchecks (time.Duration format)
KAFKA_ADDRlocalhost:39092The kafka broker addresses (can be comma separated)
KAFKA_REINDEX_REQUESTED_TOPICreindex-requestedThe name of the topic to produce messages for
KAFKA_SEC_CA_CERTSunsetCA cert chain for the server cert [1]
KAFKA_SEC_CLIENT_CERTunsetPEM for the client certificate [1]
KAFKA_SEC_CLIENT_KEYunsetPEM for the client key [1]
KAFKA_SEC_PROTOunsetif set to TLS, kafka connections will use TLS [1]
KAFKA_SEC_SKIP_VERIFYfalseignores server certificate issues if true [1]
KAFKA_VERSION1.0.2The kafka version that this service expects to connect to
LATEST_VERSIONv1The latest version of the Search Reindex API
MAX_REINDEX_JOB_RUNTIME3600sThe maximum amount of time that a reindex job is allowed to run before another reindex job can be started
MONGODB_BIND_ADDRlocalhost:27017The MongoDB bind address (aka the cluster endpoint)
MONGODB_CERT_CHAINunsetCA cert chain for the server cert
MONGODB_COLLECTIONSJobsCollection: "jobs", LocksCollection: "jobs_locks", TasksCollection: "tasks"The MongoDB collections
MONGODB_CONNECT_TIMEOUT5sThe timeout when connecting to MongoDB (time.Duration format)
MONGODB_DATABASEsearchThe MongoDB search database
MONGODB_ENABLE_READ_CONCERNfalseSwitch to use (or not) majority read concern
MONGODB_ENABLE_WRITE_CONCERNtrueSwitch to use (or not) majority write concern
MONGODB_IS_SSLfalseSwitch to use (or not) TLS when connecting to mongodb
MONGODB_PASSWORDunsetThe MongoDB Password
MONGODB_QUERY_TIMEOUT15sThe timeout for querying MongoDB (time.Duration format)
MONGODB_REPLICA_SETunsetThe name of the MongoDB replica set
MONGODB_USERNAMEunsetThe MongoDB Username
MONGODB_VERIFY_CERTfalseSwitch for whether the Mongo server certificate is to be validated or not (a major security breach not doing so)
SEARCH_API_URLhttp://localhost:23900The URL to the Search API (for creating new ElasticSearch indexes)
SERVICE_AUTH_TOKENunsetThis is required to identify the Search Reindex API when it calls the Search API POST /search endpoint
TASK_NAME_VALUESdataset-api,zebedeeThe list of permissible values that can be used for the task_name when creating a new task for a reindex job
ZEBEDEE_URLhttp://localhost:8082The URL to Zebedee (for authorisation)

Notes:

1. For more info, see the kafka TLS examples documentation

Testing

  • Run the component tests with this command go test -component
  • Run the unit tests with this command make test
  • For all details of the service endpoints use a swagger editor such as this one to view the swagger specification

When running the service (see 'Getting Started') then one can use command line tool (cURL) or REST API client (e.g. Postman) to test the endpoints:

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.

FAQs

Package last updated on 09 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc