sauloopez/go-eventual

By sauloopez

Updated 9 months ago

Handle croned and scheduled events with messaging queues

Image
Languages & frameworks
Message queues
Web servers
0

632

sauloopez/go-eventual repository overview

go-eventual

A Go service that provides event execution with SQLite and RabbitMQ. The service consumes events from a queue, stores them in a SQLite database, and produces events to appropriate queues. It uses a cron job that runs every minute to auto-execute scheduled events. This allows efficient, scalable and extensible delayed event execution.

Overview

go-eventual is designed to:

  • Consume event messages from RabbitMQ
  • Store events in a SQLite database with scheduling information
  • Execute events at the scheduled time by publishing them to RabbitMQ
  • Support different scheduling patterns (specific date, day of week, time of day)

Features

  • Event Consumption: Listens to a RabbitMQ queue for new event messages
  • Event Storage: Stores events in SQLite with scheduling metadata
  • Event Publishing: Publishes events to RabbitMQ when their scheduled time arrives
  • Scheduled Execution: Runs a cron job every minute to check for events due for execution
  • Flexible Scheduling: Supports scheduling by specific date, time of day, and day of week

Installation

Prerequisites
  • RabbitMQ server
Setup
  1. Pull this image

  2. Setup the environment variables such as:

# Database
DB_PATH=/app/data

# RabbitMQ
RABBITMQ_USER=
RABBITMQ_PASSWORD=
RABBITMQ_HOST=
RABBITMQ_PORT=5672
RABBITMQ_VHOST=/
RABBITMQ_QUEUE=eventual

Usage

Running the Image
docker run --env-file .env sauloopez/go-eventual:1.0
Event Format

Events should be sent to RabbitMQ in JSON format with the following structure:

{
  "Message": "Event content to be published",
  "ExpectedAt": "2025-05-01",
  "Exchange": "target_exchange",
  "Days": [1,2,3],
  "ExpectedClock": "15:30",
  "Times": 1
}

Where:

  • Message: The content that will be published when the event is executed (required)
  • ExpectedAt: The specific date for event execution (format: YYYY-MM-DD) (or ExpectedClock)
  • Exchange: The RabbitMQ exchange to publish to (required)
  • Days: Days of week (1-7, where 1 is Monday)
  • ExpectedClock: Time of day for execution (format: HH:MM)
  • Times: Number of times to execute the event, must be one with ExpectedAt, -1 for every and natural number major to 0. (default: 1)

Contributing

Contribute to my repo here.

Contributions are welcome! Please feel free to submit a Pull Request.

Tag summary

Content type

Image

Digest

sha256:7aacd41db

Size

11.4 MB

Last updated

9 months ago

docker pull sauloopez/go-eventual