Skip to content

Commit e2cc7e7

Browse files
committed
feat(makefile): imporve makefile & readme
1 parent a04c399 commit e2cc7e7

File tree

4 files changed

+70
-6
lines changed

4 files changed

+70
-6
lines changed

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ BINARY_NAME := discache
33
BINARY_DIR := bin
44
BINARY_PATH := $(BINARY_DIR)/$(BINARY_NAME)
55
GO_FILES := $(shell find . -type f -name '*.go')
6-
LISTEN_ADDR := :4000
7-
LEADER_ADDR := :3000
86

97
# Targets
108
.PHONY: all build clean run runfollower test lint fmt
@@ -16,10 +14,10 @@ build: $(GO_FILES)
1614
go build -o $(BINARY_PATH)
1715

1816
run: build
19-
$(BINARY_PATH)
17+
$(BINARY_PATH) start node $(or $(LISTEN_ADDR), :4000)
2018

2119
leader: build
22-
$(BINARY_PATH) start node $(LISTEN_ADDR) leader $(LEADER_ADDR)
20+
$(BINARY_PATH) start node $(or $(LISTEN_ADDR), :4000) leader $(or $(LEADER_ADDR), :3000)
2321

2422
test:
2523
@go test -v ./...

README.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,74 @@
22

33
<img src="./doc/discache.png" alt="Discache" width="700"/>
44

5-
Discache, is a powerfull, but simple LRU cache in golang. Using TCP and binary a as transporter which makes it very profomant.
5+
Discache, is a powerfull, but simple LRU cache in golang. Using TCP and binary as a transporter which makes it very performant.
6+
7+
## CLI
8+
A CLI tool has commands
9+
10+
### Requirements
11+
- Go (version 1.17 or later)
12+
13+
### Makefile Targets
14+
#### Variables
15+
- `LISTEN_ADDR` - Address for the server to listen on (default: `:4000`).
16+
- `LEADER_ADDR` - Address of the leader node (default: `:3000`).
17+
18+
These can be passed as arguments when running specific commands.
19+
20+
### Usage
21+
- Build the Project
22+
23+
```bash
24+
make build
25+
```
26+
Builds the Go binary and places it in the bin/ directory.
27+
28+
- Run the Project
29+
30+
```bash
31+
make run
32+
```
33+
Runs the binary after building it.
34+
35+
- Run the Tests
36+
37+
```bash
38+
make test
39+
```
40+
Runs all tests with verbose output.
41+
42+
- Lint the Project
43+
44+
```bash
45+
make lint
46+
```
47+
Runs golangci-lint on the codebase. Ensure golangci-lint is installed.
48+
49+
- Format the Code
50+
51+
```bash
52+
make fmt
53+
```
54+
Formats the code using go fmt.
55+
56+
- Clean the Build Files
57+
58+
```bash
59+
make clean
60+
```
61+
Removes the bin/ directory and all generated files.
62+
63+
### Example Usage
64+
To start a leader
65+
```bash
66+
make run LISTEN_ADDR=:3000
67+
```
68+
69+
To start a follower node with a custom `LISTEN_ADDR` and `LEADER_ADDR`
70+
```bash
71+
make leader LISTEN_ADDR=:3001 LEADER_ADDR=:3000
72+
```
673

774
## Client
875
A Go client for connecting to an LRU cache server over TCP. This client allows users to perform Get and Put operations on the cache, handling network communication and TTL (time-to-live) for cache entries.

bin/discache

0 Bytes
Binary file not shown.

util/util.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ type KeyNotFoundError struct {
1717
func (e *KeyNotFoundError) Error() string {
1818
return fmt.Sprintf("key %s not found", e.Key)
1919
}
20-

0 commit comments

Comments
 (0)