Skip to content

Commit

Permalink
removed unnecessary logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sahil Sarwar committed Apr 13, 2024
1 parent 6c07da9 commit a92092a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
5 changes: 2 additions & 3 deletions internal/model/kv_config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package models

import (
"fmt"
"log"
"net"
"sync"
Expand Down Expand Up @@ -51,7 +50,7 @@ func (s *KVServer) HandleClientConnect(clientID, ipAddress string, conn net.Conn

s.clients[clientID] = config

log.Printf("Client connected: ID=%s, IP=%s\n", clientID, ipAddress)
// log.Printf("Client connected: ID=%s, IP=%s\n", clientID, ipAddress)
}

// HandleClientDisconnect handles a client disconnection
Expand All @@ -61,7 +60,7 @@ func (s *KVServer) HandleClientDisconnect(clientID string, conn *net.Conn) {

if _, ok := s.clients[clientID]; ok {
delete(s.clients, clientID)
fmt.Printf("Client disconnected: ID=%s\n", clientID)
// fmt.Printf("Client disconnected: ID=%s\n", clientID)
}
}

Expand Down
14 changes: 7 additions & 7 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ func Start(config *models.Config, readySignal chan<- bool, cs *models.Collection
continue
}
}
log.Printf("adding new connection to shard: %v", shard.ShardID)
// log.Printf("adding new connection to shard: %v", shard.ShardID)
shard.DbState.AddConnection(conn.RemoteAddr().String(), &conn)
log.Printf("connected with client: %v", conn.RemoteAddr().String())
// log.Printf("connected with client: %v", conn.RemoteAddr().String())
go handleConnection(conn, cs, ts, kvServer, ps, shardConfigDb, shard)
}
}
Expand All @@ -111,7 +111,7 @@ func handleConnection(conn net.Conn, cs *models.CollectionStore, ts *models.Tran
remoteAddress := conn.RemoteAddr().String()
clientId := utils.GenerateBase64ClientID()

log.Printf("handling connection: %v for slave %v", remoteAddress, kvServer.Config.Port)
// log.Printf("handling connection: %v for slave %v", remoteAddress, kvServer.Config.Port)

kvServer.HandleClientConnect(clientId, remoteAddress, conn)

Expand All @@ -129,7 +129,7 @@ func handleConnection(conn net.Conn, cs *models.CollectionStore, ts *models.Tran
for {
// Read the next line from the connection
command, err := reader.ReadString('\n')
log.Printf("parsed command: %v", command)
// log.Printf("parsed command: %v", command)
if err != nil || command == "" {
fmt.Println("Error reading from connection:", err)
return
Expand Down Expand Up @@ -161,12 +161,12 @@ func handleConnection(conn net.Conn, cs *models.CollectionStore, ts *models.Tran
default:

result := ExecuteCommand(cmd, cs, ts, clientConfig, kvServer, ps)
log.Printf("result for cmd: %v -------- %v", cmd, result)
bytesWritten, err := fmt.Fprintln(conn, result)
// log.Printf("result for cmd: %v -------- %v", cmd, result)
_, err := fmt.Fprintln(conn, result)
if err != nil {
log.Printf("error writing to the connection: %v : [%v]", conn, err)
}
log.Printf("bytes written to conn: %v ----------- %v", conn, bytesWritten)
// log.Printf("bytes written to conn: %v ----------- %v", conn, bytesWritten)

}
}
Expand Down

0 comments on commit a92092a

Please sign in to comment.