diff --git a/chord/httpnode/client.go b/chord/httpnode/client.go index 9bf667c..1403a2f 100644 --- a/chord/httpnode/client.go +++ b/chord/httpnode/client.go @@ -13,8 +13,9 @@ import ( "path" "strings" - "git.sunturtle.xyz/zephyr/chord/chord" "github.com/go-json-experiment/json" + + "git.sunturtle.xyz/zephyr/chord/chord" ) type Client struct { diff --git a/chord/httpnode/server.go b/chord/httpnode/server.go index 5414bca..03e0bd4 100644 --- a/chord/httpnode/server.go +++ b/chord/httpnode/server.go @@ -77,7 +77,7 @@ func (n *Node) Check(ctx context.Context) error { func (n *Node) find(w http.ResponseWriter, r *http.Request) { s := r.PathValue("id") - slog.DebugContext(r.Context(), "received find", slog.String("id", s), slog.String("from", r.RemoteAddr)) + slog.DebugContext(r.Context(), "received find", slog.String("node", n.self.String()), slog.String("id", s), slog.String("from", r.RemoteAddr)) id, err := chord.ParseID(s) if err != nil { writeError(w, http.StatusBadRequest, err.Error()) @@ -89,7 +89,7 @@ func (n *Node) find(w http.ResponseWriter, r *http.Request) { return } _, addr := p.Values() - slog.DebugContext(r.Context(), "tell found", slog.String("id", s), slog.String("addr", addr.String())) + slog.DebugContext(r.Context(), "tell found", slog.String("node", n.self.String()), slog.String("id", s), slog.String("addr", addr.String())) writeOk(w, addr) } diff --git a/chord/topology.go b/chord/topology.go index a121324..74fca03 100644 --- a/chord/topology.go +++ b/chord/topology.go @@ -168,6 +168,10 @@ func (n *Node) SuccessorFailed() { n.succ[0] = n.self } +func (n *Node) String() string { + return n.self.String() +} + // Peer is the ID and address of a node. type Peer struct { id ID