Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
solr2rabbitmq is a job/library that asynchronously format and publish data from Solr query to the RabbitMQ.
You can install this library easily with pip.
pip install psql2rabbitmq
import os
import asyncio
from psql2rabbitmq import run
if __name__ == '__main__':
logger = logging.getLogger("solr2rabbitmq")
logger.setLevel(os.environ.get('LOG_LEVEL', "DEBUG"))
handler = logging.StreamHandler()
handler.setFormatter(
logging.Formatter(
os.environ.get('LOG_FORMAT', "%(asctime)s [%(levelname)s] %(name)s: %(message)s")
)
)
logger.addHandler(handler)
config = {
"mq_host": os.environ.get('MQ_HOST'),
"mq_port": int(os.environ.get('MQ_PORT', '5672')),
"mq_vhost": os.environ.get('MQ_VHOST'),
"mq_user": os.environ.get('MQ_USER'),
"mq_pass": os.environ.get('MQ_PASS'),
"mq_exchange": os.environ.get('MQ_EXCHANGE'),
"mq_routing_key": os.environ.get("MQ_ROUTING_KEY"),
"solr_collection_url": os.environ.get("SOLR_COLLECTION_URL"),
"solr_fetch_size": int(os.environ.get("SOLR_FETCH_SIZE")),
"solr_indexdate_field": os.environ.get("SOLR_INDEXDATE_FIELD"),
"solr_json_query_file_path": os.environ.get("SOLR_JSON_QUERY_FILE_PATH"),
"data_template_file_path": os.environ.get("DATA_TEMPLATE_FILE_PATH"),
"last_index_date_file_path": os.environ.get("LAST_INDEX_DATE_FILE_PATH"),
"worker_pool_size": os.environ.get("WORKER_POOL_SIZE")
}
loop = asyncio.get_event_loop()
loop.run_until_complete(run(loop=loop, logger=logger, config=config))
This library uses aio_pika, aiohttp and jinja2 packages.
You can also call this library as standalone job command. Just set required environment variables and run psql2rabbitmq
. This usecase perfectly fits when you need run it on cronjobs or kubernetes jobs.
Required environment variables:
http://solr.local:8983/solr/publication/select
)/home/user/solr_query.json
)/home/user/template.tpl
)/home/user/last_indexed_date.txt
)Example Kubernetes job: You can see it to kube.yaml
This job can be scalable using multiple instances as of version 1.1.0. If you are going to run a single instance, you don't need to set the MODE environment variable (or set it "DEFAULT"). Otherwise, you need to set the MODE environment variable to PAGINATOR or DEFAULT for one instance and CONSUMER for others.
PAGINATOR mode sends the offset values for the given query to MQ so that instances running in CONSUMER mode can work independently on the same query. In DEFAULT mode, first PAGINATOR and then CONSUMER operations run.
FAQs
Asynchronous RabbitMQ transfer job library from Apache Solr
We found that solr2rabbitmq demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.