Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Run tests and upload coverage

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

permissions:
contents: read

jobs:
test:
name: Run tests and collect coverage
runs-on: ubuntu-latest

services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install uv (with Python 3.12)
uses: astral-sh/setup-uv@v4
with:
python-version: "3.12"

- name: Install dependencies via uv
run: |
# installs main deps from [project.dependencies]
# plus dev group from [dependency-groups]
uv sync --group dev

- name: Run tests
run: |
uv run pytest --cov=fq_server --cov-branch --cov-report=xml

- name: Upload results to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: flowdacity/flowdacity-queue-server
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ docs/_build/
Dockerfile0
Dockerfile1
Dockerfile_supervisor
test_sharq.py
test_fq.py
.idea/*
venv/*
.vscode/
11 changes: 0 additions & 11 deletions .pre-commit-config.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
40 changes: 0 additions & 40 deletions .secrets.baseline

This file was deleted.

11 changes: 0 additions & 11 deletions CHANGELOG

This file was deleted.

28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# --- Build arguments with defaults ---
ARG PYTHON_VERSION=3.12
ARG PORT=8080

# --- Base image ---
FROM python:${PYTHON_VERSION}-slim

# --- Re-declare build args as env for access after FROM ---
ARG PORT
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
FQ_CONFIG=/app/docker.conf \
UV_LINK_MODE=copy \
PORT=${PORT}

WORKDIR /app

RUN pip install --no-cache-dir --upgrade uv

COPY pyproject.toml uv.lock* ./

RUN uv pip install --system --no-cache .

COPY . .

EXPOSE ${PORT}

CMD ["sh", "-c", "uvicorn asgi:app --host 0.0.0.0 --port ${PORT}"]
9 changes: 0 additions & 9 deletions Jenkinsfile

This file was deleted.

2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include LICENSE.txt README.md sharq.conf
include LICENSE.txt README.md fq.conf
47 changes: 35 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,47 @@
.PHONY: clean build install uninstall test run
.PHONY: all clean build install uninstall test publish redis redis-down

all: clean
# Default target
all: clean build

# Remove Python + build artifacts
clean:
find . -name \*.pyc -delete
find . -name \*.pyo -delete
find . -name \*~ -delete
rm -rf build dist SharQServer.egg-info
find . -name "*.pyc" -delete
find . -name "*.pyo" -delete
find . -name "*~" -delete
rm -rf dist build *.egg-info

# Build package (requires: pip install build)
build:
python setup.py sdist
python -m build

# Install locally built package
install:
pip install dist/SharQServer-*.tar.gz
pip install --force-reinstall dist/*.whl

# Uninstall FQ completely
uninstall:
yes | pip uninstall sharqserver
pip uninstall -y flowdacity-queue

# Run tests — prefers pytest, falls back to python modules
test:
python -m tests
@if python -c "import pytest" 2>/dev/null; then \
python -m pytest -q; \
else \
echo 'pytest not installed — running direct test modules'; \
python -m tests.test_routes; \
fi

run:
sharq-server --config sharq.conf
publish: clean
uv sync --group dev
uv run python -m build
# @if [ -z "$$PYPI_API_TOKEN" ]; then echo "PYPI_API_TOKEN must be set"; exit 1; fi
# uv run python -m twine upload dist/* -u __token__ -p "$$PYPI_API_TOKEN"
uv run python -m twine upload dist/*

# Start Redis container
redis:
docker compose up -d redis

# Stop Redis container
redis-down:
docker compose down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
SHARQ Server
============

SHARQ Server is an flexible, rate limited queuing system based on the [SHARQ Core library](https://github.com/plivo/sharq) and [Redis](https://redis.io).
SHARQ Server is an flexible, rate limited queuing system based on the [SHARQ Core library](https://github.com/plivo/fq) and [Redis](https://redis.io).

## Overview

SHARQ Server is a flexible, open source, rate limited queuing system. Based on the [Leaky Bucket Algorithm](http://en.wikipedia.org/wiki/Leaky_bucket#The_Leaky_Bucket_Algorithm_as_a_Queue), SHARQ lets you create queues dynamically and update their rate limits in real time.

SHARQ consists of two components - the core component and the server component. The [SHARQ core](https://github.com/plivo/sharq) is built on [Redis](https://redis.io), using Python and Lua, and the SHARQ Server is built using [Flask](http://flask.pocoo.org/) and [Gevent](http://www.gevent.org/) and talks HTTP.
SHARQ consists of two components - the core component and the server component. The [SHARQ core](https://github.com/plivo/fq) is built on [Redis](https://redis.io), using Python and Lua, and the SHARQ Server is built using [Flask](http://flask.pocoo.org/) and [Gevent](http://www.gevent.org/) and talks HTTP.

## Installation

SHARQ Server can be installed using [pip](http://pip.readthedocs.org/en/latest/installing.html) as follows:

```
pip install sharqserver
pip install fqserver
```

## Running the server

SHARQ server can be started with the following command. A simple SHARQ config file can be [found here](https://github.com/plivo/sharq-server/blob/master/sharq.conf).
SHARQ server can be started with the following command. A simple SHARQ config file can be [found here](https://github.com/plivo/fq-server/blob/master/fq.conf).

```
$sharq-server --config sharq.conf
$fq-server --config fq.conf
```

Ensure the SHARQ server is up by making a HTTP request.

```
$curl http://127.0.0.1:8080/
{
"message": "Hello, SharQ!"
"message": "Hello, FQ!"
}
```

## Documentation

Check out [sharq.io](http://sharq.io) for documentation.
Check out [fq.io](http://fq.io) for documentation.

## License

Expand Down
14 changes: 14 additions & 0 deletions asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2025 Flowdacity Team. See LICENSE.txt for details.
# ASGI application entrypoint for Flowdacity Queue (FQ) Server

import os
from fq_server import setup_server

# read config path from env variable, fallback to ./default.conf
fq_config_path = os.environ.get("FQ_CONFIG", "./default.conf")
fq_config_path = os.path.abspath(fq_config_path)

server = setup_server(fq_config_path)

# ASGI app exposed for Uvicorn/Hypercorn
app = server.app
18 changes: 0 additions & 18 deletions catalog-mms-mpssharq.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions catalog-mms-npssharq.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions catalog-npssharq-clustered.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions catalog-rcs-mpssharq.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions catalog-rcs-npssharq.yaml

This file was deleted.

Loading