rssreader

module
v0.0.0-...-26a4b9a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2025 License: MIT-0

README

RSS Reader Service

This project is an RSS Reader service written in Go. It fetches and parses RSS feeds, providing a simple API to access the feed data.

Setup

Pre-requisites
  • Go 1.23 or later
  • Docker
  • Docker Compose
  • Unoccupied ports local ports 33672, 44672
  • A working internet connection
  • Make
Running the service

To run the service, execute the following command:

make dev-run

This will start the service and the rabbitmq in the docker container. It will let you interact with the service using the rabbitmq management console at localhost:33672. You can find the RabbitMQ Docker Compose configuration in the tools/docker/rabbitmq/docker-compose.yml file.

Running the tests

To run the tests, execute the following command:

⚠️ Warning: Running the following command will force restart the message broker.

make test

As a result, you can see the test coverage report in .reports/.

Stopping the service

To stop the service, execute the following command:

make dev-stop

API

All interaction between the service and the clients is done through the RabbitMQ message broker. The service listens to the rss_request queue and expects messages in the following format:

{
  "urls": ["url1", "url2", "url3"]
}

The service will respond to the client by sending messages to the queue specified in the reply_to field of the request message. The response message will have the following format:

{
    "items": [
        {
            "title":        "<ProperValue>",
            "source":       "<ProperValue>",
            "source_url":   "<ProperValue>",
            "link":         "<ProperValue>",
            "publish_date": "<ProperValue>",
            "description":  "<ProperValue>"
        }
        ...
    ],
    "failed_items": [
        {
            "source_url":   "<ProperValue>",
            "error":        "<ProperValue>"
        }
        ...
    ]

Configuration

The service can be configured by changing the values in the config.json file. The following is the default configuration:

{
    "logger": {
        "level": "debug"
    },
    "broker": {
        "connection_url": "amqp://emerchantpay:qwe123qwe@localhost:33672/",
        "listen_queue_name": "rss_request",
        "prefetch_count": 1
    },
    "converter": {
        "max_parallel_parses": 1,
        "max_parallel_url_per_request": 10
    }
}
Broker configuration
  • connection_url: The URL of the RabbitMQ broker.
  • listen_queue_name: The name of the queue the service listens to.
  • prefetch_count: The number of messages the service can fetch from the queue at once.
Converter configuration
  • max_parallel_parses: The number of parallel handling requests.
  • max_parallel_url_per_request: The number of parallel handling URLs per request.

TODO

  • Support authentication
  • Provide the public key to encrypt message (since all messages are sent to the same queue)
  • Add more tests
  • Support SSL for RabbitMQ
  • Fix coverage report for integration tests
  • Fix TODOs in the code

Directories

Path Synopsis
internal
pkg
tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL