Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ondrejsika/counter

Repository files navigation

ondrejsika/counter

Configuration

  • BACKEND - Storage enginge for counter, default redis. Values can be redis, inmemory, postgres, or mongodb.
  • PORT - port to listen on (default: 8000)
  • REDIS - Redis host (default: 127.0.0.1)
  • REDIS_PASSWORD - Redis password (default: '' - empty string)
  • POSTGRES_HOST - Postgres host (default: 127.0.0.1)
  • POSTGRES_USER - Postgres user (default: postgres)
  • POSTGRES_PASSWORD - Postgres password (default: pg)
  • POSTGRES_DATABASE - Postgres database (default: postgres)
  • POSTGRES_SSLMODE - Postgres SSL mode (default: disable, values can be disable, require)
  • MONGODB_URI - MongoDB host (default: mongodb://127.0.0.1:27017)
  • SLOW_START - Time in seconds to wait before start (default: 0)
  • EXTRA_TEXT - Extra text to display (default: '')

API Endpoints

Counter Endpoints

  • GET / - Get counter value with UI rendering (HTML for browsers, plain text for curl)
  • GET /api/counter - Get counter value in JSON format

Health Check Endpoints

  • GET /api/livez or GET /livez - for liveness probe
  • GET /api/readyz or GET /readyz - for readiness probe

Information Endpoints

  • GET /api/version or GET /version - Get application version
  • GET /api/status or GET /status - Get application status and runtime information

Monitoring Endpoints

  • GET /metrics - Prometheus metrics endpoint

Images

  • ondrejsika/counter
  • ghcr.io/ondrejsika/counter

Run Dependencies

Redis

docker run --name redis -d -p 6379:6379 redis

Get counter value from Redis

docker exec redis redis-cli get counter

MongoDB

docker run --name mongodb -d -p 27017:27017 mongo

Get counter value from MongoDB

docker exec -it mongodb mongosh counter --eval 'db.counter.find()'

Postgres

docker run --name postgres -d -p 5432:5432 -e POSTGRES_PASSWORD=pg postgres

Get counter value from Postgres

docker exec postgres psql -U postgres -c 'SELECT * FROM counters'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •