11package node
22
33import (
4- "encoding/binary"
5- "fmt"
6-
74 "github.com/unpackdev/fdb/db"
85 "github.com/unpackdev/fdb/logger"
96 "github.com/unpackdev/fdb/observability"
@@ -43,15 +40,15 @@ func (wh *DbWriteHandler) ForceFlush() {
4340
4441// Handle processes the incoming message using the TCPWriteHandler
4542func (wh * DbWriteHandler ) Handle (conn transports.Connection , frame []byte ) {
46- fmt .Println ("DID I REACH WRITE DB HANLDER? FRAME LENGTH:" , len (frame ))
43+ // fmt.Println("DID I REACH WRITE DB HANLDER? FRAME LENGTH:", len(frame))
4744 // Debug the raw incoming frame
48- fmt .Printf ("WRITE HANDLER RAW FRAME (first 20 bytes): %v\n " , frame [:min (20 , len (frame ))])
45+ // fmt.Printf("WRITE HANDLER RAW FRAME (first 20 bytes): %v\n", frame[:min(20, len(frame))])
4946
5047 // Check if first byte is our special marker 0xF0
5148 offset := 0
5249 if len (frame ) > 0 && frame [0 ] == 0xF0 {
5350 offset = 1 // Skip the marker byte
54- fmt .Println ("DETECTED MARKER BYTE 0xF0, offset set to" , offset )
51+ // fmt.Println("DETECTED MARKER BYTE 0xF0, offset set to", offset)
5552 }
5653
5754 // Adjust minimum length check based on whether we have a marker
@@ -80,15 +77,15 @@ func (wh *DbWriteHandler) Handle(conn transports.Connection, frame []byte) {
8077 }
8178
8279 // Debug action byte
83- actionByte := frame [offset ]
84- fmt .Printf ("ACTION BYTE: 0x%02x\n " , actionByte )
80+ // actionByte := frame[offset]
81+ // fmt.Printf("ACTION BYTE: 0x%02x\n", actionByte)
8582
8683 // Create a [32]byte key from the frame without using the pool
8784 var key [32 ]byte
8885 copy (key [:], frame [offset + 1 :offset + 33 ]) // Copy directly from frame, accounting for offset
8986
9087 // Debug the key being extracted
91- fmt .Printf ("KEY (first 8 bytes): %v\n " , key [:8 ])
88+ // fmt.Printf("KEY (first 8 bytes): %v\n", key[:8])
9289
9390 // For the message protocol format: [1-byte action][32-byte key][4-byte length][actual data]
9491 // We need to skip 4 bytes after the key to get to the actual data
@@ -114,7 +111,7 @@ func (wh *DbWriteHandler) Handle(conn transports.Connection, frame []byte) {
114111 // Extract only the actual data, skipping the length field
115112 value := frame [valueStart :]
116113
117- fmt .Printf ("ACTUAL VALUE (first %d bytes): %v\n " , min (10 , len (value )), value [:min (10 , len (value ))])
114+ // fmt.Printf("ACTUAL VALUE (first %d bytes): %v\n", min(10, len(value)), value[:min(10, len(value))])
118115
119116 // Add detailed logging for debugging large payload issues
120117 wh .logger .Debug ("Received write request" ,
@@ -125,7 +122,7 @@ func (wh *DbWriteHandler) Handle(conn transports.Connection, frame []byte) {
125122 zap .Binary ("value_prefix" , value [:min (10 , len (value ))]))
126123
127124 // Log what we're about to write to the database
128- fmt .Printf ("ABOUT TO WRITE TO DB - KEY: %v, VALUE (first 20 bytes): %v\n " , key [:8 ], value [:min (20 , len (value ))])
125+ // fmt.Printf("ABOUT TO WRITE TO DB - KEY: %v, VALUE (first 20 bytes): %v\n", key[:8], value[:min(20, len(value))])
129126
130127 // Buffer the write request with the key as [32]byte
131128 err := wh .writer .BufferWrite (key , value )
@@ -144,7 +141,7 @@ func (wh *DbWriteHandler) Handle(conn transports.Connection, frame []byte) {
144141
145142 // Encode the response to bytes
146143 response := dbResp .Encode ()
147- fmt .Printf ("SENDING ERROR RESPONSE: %v\n " , response [:min (20 , len (response ))])
144+ // fmt.Printf("SENDING ERROR RESPONSE: %v\n", response[:min(20, len(response))])
148145 conn .Send (response )
149146 return
150147 }
@@ -174,12 +171,12 @@ func (wh *DbWriteHandler) Handle(conn transports.Connection, frame []byte) {
174171 response := dbResp .Encode ()
175172
176173 // Detailed debug of the full response being sent
177- fmt .Println ("SENDING WRITE SUCCESS RESPONSE" , response [:min (20 , len (response ))], "with status byte:" , response [0 ])
178- fmt .Printf ("FULL RESPONSE DETAILS:\n - Status: %d\n - Length bytes: %v (uint32: %d)\n - Data: %v\n " ,
179- response [0 ],
180- response [1 :5 ],
181- binary .BigEndian .Uint32 (response [1 :5 ]),
182- response [5 :min (25 , len (response ))])
174+ // fmt.Println("SENDING WRITE SUCCESS RESPONSE", response[:min(20, len(response))], "with status byte:", response[0])
175+ // fmt.Printf("FULL RESPONSE DETAILS:\n - Status: %d\n - Length bytes: %v (uint32: %d)\n - Data: %v\n",
176+ // response[0],
177+ // response[1:5],
178+ // binary.BigEndian.Uint32(response[1:5]),
179+ // response[5:min(25, len(response))])
183180
184181 // Send the formatted response back to the client
185182 conn .Send (response )
0 commit comments