-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
107 lines (85 loc) · 2 KB
/
Justfile
File metadata and controls
107 lines (85 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Default recipe - show available commands
default:
@just --list
# Run the server
run:
go run main.go
# Clean WAL file and run server
clean-run:
rm -f wal.txt
go run main.go
# Run all tests
test:
go test ./...
# Run tests with race detector
test-race:
go test -race ./...
# Run tests with coverage
test-coverage:
go test -cover ./...
# Build the binary
build:
go build -o mkv main.go
# Clean build artifacts and WAL
clean:
rm -f mkv wal.txt
# TODO: check for binary installed and do so if not
# Format code
fmt:
gofumpt -w
# Lint code (requires golangci-lint)
lint:
golangci-lint run
# PUT a key-value pair
put key value:
curl -X PUT http://localhost:8080/keys/{{key}} -d "{{value}}"
# GET a key
get key:
curl http://localhost:8080/keys/{{key}}
# DELETE a key
delete key:
curl -X DELETE http://localhost:8080/keys/{{key}}
# Create snapshot
snapshot:
curl -X POST http://localhost:8080/snapshot
# Example workflow: put, get, delete
demo:
@echo "Putting hello=world..."
@just put hello world
@echo "\nGetting hello..."
@just get hello
@echo "\nDeleting hello..."
@just delete hello
@echo "\nTrying to get deleted key (should 404)..."
@just get hello || true
# Populate store with test data
populate:
@just put user1 "Alice"
@just put user2 "Bob"
@just put counter "42"
@just put status "active"
@echo "Store populated with test data"
# Watch WAL file contents
watch-wal:
tail -f wal.txt
# Check WAL file contents
show-wal:
cat wal.txt
# Run server in background and run demo
run-demo:
#!/usr/bin/env bash
echo "Starting server in background..."
go run main.go &
SERVER_PID=$!
# Wait for server to be ready (max 10 seconds)
for i in {1..20}; do
if curl -s http://localhost:8080/keys/test > /dev/null 2>&1; then
echo "Server ready!"
break
fi
sleep 0.5
done
# Run demo
just demo
# Clean up
kill $SERVER_PID