From 4553be4b6db646bf40d43cc328370636601ec130 Mon Sep 17 00:00:00 2001 From: AYM1607 Date: Thu, 5 Aug 2021 16:26:54 -0500 Subject: [PATCH] Fix typs and add extra clarifications for segment and the http server. --- internal/log/segment.go | 3 ++- internal/server/http.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/log/segment.go b/internal/log/segment.go index d0a40a1..bdb5471 100644 --- a/internal/log/segment.go +++ b/internal/log/segment.go @@ -52,7 +52,7 @@ func newSegment(dir string, baseOffset uint64, c Config) (*segment, error) { } // If Read(-1) returns an error it means that the index's underlying file - // and this itself is empty. + // and thus itself is empty. if off, _, err := s.index.Read(-1); err != nil { s.nextOffset = baseOffset } else { @@ -138,6 +138,7 @@ func (s *segment) Remove() error { // nearestMultiple returns the nearest and lesser multiple of k in j. // example: nearestMultiple(9, 4) = 8 func nearestMultiple(j, k uint64) uint64 { + // This code comes from the book. is this check necessary since the passed values are uint64? if j >= 0 { return (j / k) * k } diff --git a/internal/server/http.go b/internal/server/http.go index bf2e8f8..f740bf9 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -67,7 +67,7 @@ func (s *httpServer) handleProduce(w http.ResponseWriter, r *http.Request) { } res := ProduceResponse{Offset: off} - // The header gets overrided if there's an encoding error. + // The header gets overwritten if there's an encoding error. w.WriteHeader(http.StatusCreated) err = json.NewEncoder(w).Encode(res) if err != nil {