go-link-shortener-backend, v1.1
Posted on

Back-end of the service for shorting links.
Using sequential counters for generating link codes; storing counters chunks in the etcd database.
Change Log
- generating link codes:
- using sequential counters:
- formatting:
- formatting a counter as an integer number in the 10 base;
- storing:
- storing in a database only counters chunks;
- storing counters themselves in memory;
- sharding:
- sharding counters chunks;
- selecting a shard of a counter chunk at random;
- using the etcd database:
- using a record revision as a counter chunk.
- formatting:
- using sequential counters:
Features
- RESTful API:
- link model:
- creating by an URL;
- getting by a code;
- representing in a JSON:
- payloads:
- of requests;
- of responses;
- errors;
- payloads:
- link model:
- generating link codes:
- using a version 4 UUID;
- using sequential counters:
- formatting:
- formatting a counter as an integer number in the 10 base;
- storing:
- storing in a database only counters chunks;
- storing counters themselves in memory;
- sharding:
- sharding counters chunks;
- selecting a shard of a counter chunk at random;
- formatting:
- server:
- storing settings in environment variables;
- supporting graceful shutdown;
- databases:
- distributing:
- Docker image;
- Docker Compose configuration.
Usage
$ go-link-shortener
Environment variables:
SERVER_ADDRESS— server URI (default::8080);CACHE_ADDRESS— Redis connection URI (default:localhost:6379);STORAGE_ADDRESS— MongoDB connection URI (default:mongodb://localhost:27017);COUNTER_ADDRESS— etcd connection URI (default:localhost:2379);COUNTER_COUNT— count of distributed counters (default:2);COUNTER_CHUNK— step of a distributed counter (default:1000).
Repository
Link: https://github.com/thewizardplusplus/go-link-shortener-backend/tree/v1.1.
Content: code.
License: MIT.