This project is a distributed log system implemented in Go. It provides a gRPC-based API for producing and consuming log records, with features such as streaming, error handling, and efficient storage management.
- gRPC API: Supports producing and consuming log records via gRPC.
- Streaming: Enables streaming of log records for efficient data transfer.
- Error Handling: Implements custom error types for robust error reporting.
- Efficient Storage: Uses segmented storage with indexing for fast reads and writes.
- Testing: Comprehensive unit tests for all components.
The project is organized as follows:
/api/v1/ # Protocol Buffers definitions and generated Go code for the gRPC API.
log.proto # The Protobuf definition for the log service.
log.pb.go # Generated Go code for Protobuf messages.
log_grpc.pb.go # Generated Go code for gRPC service.
error.go # Custom error types for the API.
/internal/log/ # Core log implementation.
log.go # Main log implementation with segmented storage.
store.go # Storage layer for log records.
index.go # Indexing layer for fast record lookups.
segment.go # Segment abstraction for log storage.
config.go # Configuration for log segments.
store_test.go # Unit tests for the storage layer.
index_test.go # Unit tests for the indexing layer.
segment_test.go # Unit tests for the segment abstraction.
log_test.go # Unit tests for the main log implementation.
/internal/server/ # gRPC server implementation.
server.go # gRPC server for the log service.
server_test.go # Unit tests for the gRPC server.
/github/workflows/ # GitHub Actions for CI/CD.
test.yml # Workflow for running tests on push.
/Makefile # Makefile for building, testing, and running the project.
- Go 1.24 or later
- Protocol Buffers compiler (
protoc
) protoc-gen-go
andprotoc-gen-go-grpc
plugins
-
Clone the repository:
git clone https://github.com/Gibson-Gichuru/prolog.git cd prolog
-
Install dependencies:
go mod download
-
Generate Protobuf code (if needed):
protoc --go_out=. --go-grpc_out=. api/v1/log.proto
To build the project, run:
make build
This will create an executable named app
.
To start the server, run:
make run
The server will start and listen for gRPC requests.
To run the tests, use:
make test
This will execute all unit tests in the project.
The gRPC API provides the following methods:
- Produce: Appends a record to the log.
- Consume: Reads a record from the log by offset.
- ProduceStream: Streams records to the log.
- ConsumeStream: Streams records from the log starting at a given offset.
message ProduceRequest {
Record record = 1;
}
message ConsumeRequest {
uint64 offset = 1;
}
message Record {
bytes value = 1;
uint64 offset = 2;
}
The project includes comprehensive unit tests for all components. Tests are located in the internal/log
and internal/server
directories. To run the tests, use:
make test
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes with clear messages.
- Submit a pull request.
This project is licensed under the MIT License. See the LICENSE
file for details.