Skip to content

Add HTTP REST API, multi-connection support, tests, CI, and lint - #2

Merged
Ayan-sh03 merged 1 commit into
mainfrom
feature/http-rest-api
May 24, 2026
Merged

Add HTTP REST API, multi-connection support, tests, CI, and lint#2
Ayan-sh03 merged 1 commit into
mainfrom
feature/http-rest-api

Conversation

@Ayan-sh03

Copy link
Copy Markdown
Owner

Summary

  • HTTP REST API on :8080 alongside existing RESP on :6379 — both protocols share the same data stores and handler functions. Endpoints cover KV CRUD, list push/range/pop, hash CRUD, INCR/DECR/INCRBY/DECRBY/APPEND, and ping.
  • Fix single-connection bug — main.go now accepts multiple concurrent TCP connections via accept loop with goroutines.
  • Add HDEL command to stdhash (was missing from Handlers map and AOF write list).
  • Add 49 unit tests across 5 test files: handler, stdhash, cuckoo hash, RESP parser, and HTTP API.
  • Add GitHub Actions CI (build, vet, test -race, golangci-lint) and .golangci.yml with 13 linters.
  • Fix lint issues: unused Value.num field, unchecked errors in RESP reader, comment formatting, increment style, nil checks around range, SA4008.

Test plan

  • go test -race ./... — all 49 tests pass
  • golangci-lint run ./... — clean
  • Manual: go build and run — both RESP (:6379) and HTTP (:8080) work
  • CI workflow added at .github/workflows/ci.yml

- Add HTTP REST API on :8080 (api.go) alongside RESP on :6379
  - KV CRUD: PUT/GET/DELETE /kv/{key}, INCR/DECR/INCRBY/DECRBY/APPEND
  - List: PUT/GET/POST /list/{key} with push/range/pop
  - Hash: PUT/GET/DELETE /hash/{key}/{field}, GET /hash/{key}
  - GET /ping for health check
  - AOF write-through for all mutating commands

- Fix single-connection bug: main.go now accepts multiple concurrent
  TCP connections via accept loop with goroutines

- Add HDEL command to stdhash (was missing from Handlers map)

- Add comprehensive unit tests (49 tests total):
  - handler_test.go: string commands, wrong args, concurrent SET
  - stdhash_test.go: HSET/HGET/HGETALL/HDEL
  - hashes_test.go: cuckoo hash CHSET/CHGET/CHGETALL/CHDEL, resize
  - resp_test.go: marshal/unmarshal, round-trip, writer
  - api_test.go: HTTP REST endpoints for all operations

- Add GitHub Actions CI (.github/workflows/ci.yml):
  build, vet, test -race, golangci-lint

- Add .golangci.yml with 13 linters enabled

- Fix lint issues: unused Value.num field, unchecked errors in
  RESP reader, comment formatting, increment style, nil check
  around range, SA4008 in cuckoo hash
@Ayan-sh03
Ayan-sh03 merged commit a4aa998 into main May 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant