include self addr in logging
This commit is contained in:
parent
af65c66317
commit
dd75fb281a
@ -13,8 +13,9 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.sunturtle.xyz/zephyr/chord/chord"
|
|
||||||
"github.com/go-json-experiment/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
|
||||||
|
"git.sunturtle.xyz/zephyr/chord/chord"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
@ -77,7 +77,7 @@ func (n *Node) Check(ctx context.Context) error {
|
|||||||
|
|
||||||
func (n *Node) find(w http.ResponseWriter, r *http.Request) {
|
func (n *Node) find(w http.ResponseWriter, r *http.Request) {
|
||||||
s := r.PathValue("id")
|
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)
|
id, err := chord.ParseID(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeError(w, http.StatusBadRequest, err.Error())
|
writeError(w, http.StatusBadRequest, err.Error())
|
||||||
@ -89,7 +89,7 @@ func (n *Node) find(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, addr := p.Values()
|
_, 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)
|
writeOk(w, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,6 +168,10 @@ func (n *Node) SuccessorFailed() {
|
|||||||
n.succ[0] = n.self
|
n.succ[0] = n.self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *Node) String() string {
|
||||||
|
return n.self.String()
|
||||||
|
}
|
||||||
|
|
||||||
// Peer is the ID and address of a node.
|
// Peer is the ID and address of a node.
|
||||||
type Peer struct {
|
type Peer struct {
|
||||||
id ID
|
id ID
|
||||||
|
Loading…
Reference in New Issue
Block a user