reports-service

command module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 15 Imported by: 0

README

reports-service

A REST API demonstrating fiber + Cassandra + SFTP under Argos: pulling a report fetches it from an SFTP server and records its metadata in Cassandra.

What this demonstrates

Concern Argos module Where
HTTP server tracing/metrics (fasthttp-based) integrations/httpserver/fiber handlers.go - argosfiber.Middleware()
Cassandra query/batch tracing/metrics integrations/cassandra main.go - argoscassandra.New() set as cluster.QueryObserver/BatchObserver
SFTP client tracing/metrics integrations/sftp reports.go - argossftp.Wrap(...)
Init/Shutdown/Logger core main.go

Fiber runs on fasthttp, not net/http - handlers must read the span-carrying context via c.UserContext() (set by argosfiber.Middleware), not the raw c.Context(); see the comment in handlers.go.

The sample only measures a pulled file's size rather than parsing its content (reports.go) - that's business logic outside what this sample demonstrates, which is the SFTP wrapper itself.

Run it

docker compose up -d      # cassandra:5, atmoz/sftp (seeded with testdata/sample-report.csv)
go run .                  # listens on :8084
curl http://localhost:8084/healthz

curl -X POST http://localhost:8084/reports/pull \
  -H "Content-Type: application/json" \
  -d '{"path":"/upload/sample-report.csv"}'
# {"filename":"sample-report.csv","size_bytes":72,"pulled_at":"..."}

curl http://localhost:8084/reports/sample-report.csv
docker compose down -v

Configuration

Env var Default
HTTP_ADDR :8084
CASSANDRA_HOST localhost
CASSANDRA_KEYSPACE reports
SFTP_ADDR localhost:2222
SFTP_USER / SFTP_PASSWORD reports / reports
OTEL_EXPORTER_OTLP_ENDPOINT localhost:4317 (Argos fails open if unreachable)

To see traces/metrics, run the repo's root docker/docker-compose.otel.yml (make otel-up from the repo root).

Documentation

Overview

Command reports-service is a runnable Argos sample: a fiber REST API that pulls report files from an SFTP server and records their metadata in Cassandra. It demonstrates argosfiber (server middleware, fasthttp-based), argoscassandra (QueryObserver/BatchObserver), and argossftp (client wrapper) wired together under one argos.Init. See README.md for how to run it.

Jump to

Keyboard shortcuts

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