This is a distributed logging service that provides the ability to store and read log records. The service is composed of an HTTP server that exposes the API endpoints for appending and reading log records, and a log store that persists the log records to disk.
The following instructions will guide you on how to build, run, and test the service.
- Go 1.17 or higher
- Protocol buffers compiler (protoc) 3.0 or higher
To build the service, run the following command:
make build
This will compile the HTTP server binary into the bin/proglog
directory.
To run the service, run the following command:
make run
This will start the HTTP server on port 8080.
The following API endpoints are available:
POST /v1/records
: Appends a new log record.
Request:
{ "value": "The byte array of the log record to be appended." }
Response:
{ "offset": "The offset of the newly appended record." }
GET /v1/records/{offset}
: Reads a log record at the specified offset.
Request URL parameters:
offset
: The offset of the log record to be read.
Response:
{ "value": "The byte array of the log record." }
To run the tests, run the following command:
make test
This will run the unit tests for the log store.
The code for the service is organized as follows:
api/v1/log.proto
: The protocol buffer definition for the API endpoints.bin/proglog/proglog
: The HTTP server binary.cmd/server/main.go
: The main function that starts the HTTP server.internal/log/store.go
: The log store implementation.internal/log/store_test.go
: The unit tests for the log store.
This project is licensed under the MIT License - see the LICENSE
file for details.