dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3384db611b build(deps): bump the gomod-minor-patch group across 1 directory with 6 updates (#5)
Bumps the gomod-minor-patch group with 6 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [github.com/couchbase/gocb/v2](https://github.com/couchbase/gocb) | `2.9.4` | `2.12.3` |
| [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) | `1.8.1` | `1.10.0` |
| [github.com/lib/pq](https://github.com/lib/pq) | `1.10.9` | `1.12.3` |
| [github.com/redis/go-redis/v9](https://github.com/redis/go-redis) | `9.17.1` | `9.19.0` |
| [github.com/valkey-io/valkey-go](https://github.com/valkey-io/valkey-go) | `1.0.65` | `1.0.75` |
| [go.mongodb.org/mongo-driver/v2](https://github.com/mongodb/mongo-go-driver) | `2.0.0` | `2.6.0` |



Updates `github.com/couchbase/gocb/v2` from 2.9.4 to 2.12.3
- [Commits](https://github.com/couchbase/gocb/compare/v2.9.4...v2.12.3)

Updates `github.com/go-sql-driver/mysql` from 1.8.1 to 1.10.0
- [Release notes](https://github.com/go-sql-driver/mysql/releases)
- [Changelog](https://github.com/go-sql-driver/mysql/blob/master/CHANGELOG.md)
- [Commits](https://github.com/go-sql-driver/mysql/compare/v1.8.1...v1.10.0)

Updates `github.com/lib/pq` from 1.10.9 to 1.12.3
- [Release notes](https://github.com/lib/pq/releases)
- [Changelog](https://github.com/lib/pq/blob/master/CHANGELOG.md)
- [Commits](https://github.com/lib/pq/compare/v1.10.9...v1.12.3)

Updates `github.com/redis/go-redis/v9` from 9.17.1 to 9.19.0
- [Release notes](https://github.com/redis/go-redis/releases)
- [Changelog](https://github.com/redis/go-redis/blob/master/RELEASE-NOTES.md)
- [Commits](https://github.com/redis/go-redis/compare/v9.17.1...v9.19.0)

Updates `github.com/valkey-io/valkey-go` from 1.0.65 to 1.0.75
- [Release notes](https://github.com/valkey-io/valkey-go/releases)
- [Commits](https://github.com/valkey-io/valkey-go/compare/v1.0.65...v1.0.75)

Updates `go.mongodb.org/mongo-driver/v2` from 2.0.0 to 2.6.0
- [Release notes](https://github.com/mongodb/mongo-go-driver/releases)
- [Commits](https://github.com/mongodb/mongo-go-driver/compare/v2.0.0...v2.6.0)

---
updated-dependencies:
- dependency-name: github.com/couchbase/gocb/v2
  dependency-version: 2.12.3
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: gomod-minor-patch
- dependency-name: github.com/go-sql-driver/mysql
  dependency-version: 1.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: gomod-minor-patch
- dependency-name: github.com/lib/pq
  dependency-version: 1.12.3
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: gomod-minor-patch
- dependency-name: github.com/redis/go-redis/v9
  dependency-version: 9.19.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: gomod-minor-patch
- dependency-name: github.com/valkey-io/valkey-go
  dependency-version: 1.0.75
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: gomod-minor-patch
- dependency-name: go.mongodb.org/mongo-driver/v2
  dependency-version: 2.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: gomod-minor-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-23 18:11:04 +07:00

db-keepalive

Pluggable Go daemon that performs a periodic counter increment to prevent free-tier database clusters (Redis Cloud, Valkey, Aiven, Neon, Supabase, MongoDB Atlas, Couchbase Capella, etc.) from being auto-paused for inactivity.

Successor to the *-keepalive family: one binary, one image, six adapters.

Supported drivers

DB_TYPE Driver Env vars
redis github.com/redis/go-redis/v9 REDIS_URL
valkey github.com/valkey-io/valkey-go VALKEY_URL
postgresql github.com/lib/pq SERVICE_URI
mysql github.com/go-sql-driver/mysql DATA_SOURCE_NAME
mongodb go.mongodb.org/mongo-driver/v2 MONGODB_URI, MONGODB_DATABASE, MONGODB_COLLECTION
couchbase github.com/couchbase/gocb/v2 COUCHBASE_CONNECTION_STRING, COUCHBASE_USERNAME, COUCHBASE_PASSWORD, COUCHBASE_BUCKET_NAME, COUCHBASE_SCOPE_NAME, COUCHBASE_COLLECTION_NAME

Optional: INTERVAL (e.g. 30s, 5m; default 1m), COUNTER_KEY (default counter).

Quick start (Docker)

docker run -d --name db-keepalive --restart unless-stopped \
  -e DB_TYPE=redis \
  -e REDIS_URL='redis://default@host:6379' \
  ghcr.io/tiennm99/db-keepalive:latest

Quick start (local)

git clone https://github.com/tiennm99/db-keepalive
cd db-keepalive
cp .env.example .env       # then edit DB_TYPE + the driver's env vars
go run .

How it works

On every tick the chosen adapter performs the cheapest write that proves the cluster is alive:

  • Redis/ValkeyINCR counter
  • PostgreSQLUPDATE keepalive SET value = value + 1 WHERE key = 'counter' RETURNING value
  • MySQLUPDATE + SELECT inside a transaction
  • MongoDBFindOneAndUpdate({_id: "counter"}, {$inc: {count: 1}}, upsert)
  • CouchbaseGET counter++UPSERT counter

The PostgreSQL and MySQL adapters expect a table:

CREATE TABLE keepalive (key TEXT PRIMARY KEY, value BIGINT NOT NULL DEFAULT 0);
INSERT INTO keepalive (key, value) VALUES ('counter', 0);

(MySQL uses backticked identifiers — see adapter/mysql.go.)

Adding a new database

  1. Create adapter/<name>.go.
  2. Implement the Adapter interface in adapter/adapter.go (Connect, Increment, Close).
  3. Register the factory in init():
    func init() { Registry["<name>"] = func() (Adapter, error) { return &myAdapter{}, nil } }
    
  4. Add an import _ "your driver" if needed, and the env vars to .env.example and the table above.

Migrated from

This repo replaces six single-database repos. All are archived with a pointer here:

License

Apache-2.0 — see LICENSE.

S
Description
Pluggable Go keepalive daemon for free-tier DB clusters — Redis, Valkey, PostgreSQL, MySQL, MongoDB, Couchbase. Successor to *-keepalive family.
Readme Apache-2.0
380 KiB
Languages
Go 99.2%
Dockerfile 0.8%