Skip to content

Commit

Permalink
BREAKING CHANGE: netcore: scope non-common fields
Browse files Browse the repository at this point in the history
1. `domain` => `dnsLookupDomain`

2. `addrs` => `dnsResolvedAddrs`

3. `count` => `ioBufferSize` or `ioBufferCount`

This set of changes is part of an overall effort to ensure it's
relatively trivial to serialize to a flat data format.

To this end, figure out which fields are really common and which
fields, instead, are specific, and add prefixes to the specific ones
to make it very clear what they are about.

Also, avoid overload, and split into two fields when we're using
the same field with two distinct semantics dependent on the
message type. This should also increase the data format orthogonality.

See also rbmk-project/dnscore#13
  • Loading branch information
bassosimone committed Nov 29, 2024
1 parent 259541e commit 36619f9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.23.3

require (
github.com/miekg/dns v1.1.62
github.com/rbmk-project/common v0.3.0
github.com/rbmk-project/dnscore v0.5.0
github.com/rbmk-project/common v0.4.0
github.com/rbmk-project/dnscore v0.6.0
github.com/rogpeppe/go-internal v1.13.1
golang.org/x/sys v0.27.0
)
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ=
github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rbmk-project/common v0.3.0 h1:g9iX/lg5kvzmgxgr4xbkcCjA2jfazM1zAyLKzLD/3iU=
github.com/rbmk-project/common v0.3.0/go.mod h1:uzrFIJl8SEOpgS2pSeBFLUgqc4D1lIcGk/EYuxkFO0U=
github.com/rbmk-project/dnscore v0.5.0 h1:GaWr4SUJFJzjAgkZ9kJdS0I0BWHPnObD/lZaZzPfB9c=
github.com/rbmk-project/dnscore v0.5.0/go.mod h1:ENuxqOG44rTIByt412eghWPRvTg/G5RkE6Truv+tapQ=
github.com/rbmk-project/common v0.4.0 h1:gw7f/YdPxcUZ81cO9IMzEPDhsc6tOUte1m0OFi6euFg=
github.com/rbmk-project/common v0.4.0/go.mod h1:uzrFIJl8SEOpgS2pSeBFLUgqc4D1lIcGk/EYuxkFO0U=
github.com/rbmk-project/dnscore v0.6.0 h1:23rRsLBwTkQqJQMVPf4kimzGSZsw29EY7u3ffHbWkKg=
github.com/rbmk-project/dnscore v0.6.0/go.mod h1:Ct9RhR8HTI6tnq6/HSbzB/F8bk3k7E/6hmEctxSecUQ=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
Expand Down
8 changes: 4 additions & 4 deletions netcore/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (c *connWrapper) Read(buf []byte) (int, error) {
c.netx.Logger.InfoContext(
c.ctx,
"readStart",
slog.Int("count", len(buf)),
slog.Int("ioBufferSize", len(buf)),
slog.String("localAddr", c.laddr),
slog.String("protocol", c.protocol),
slog.String("remoteAddr", c.raddr),
Expand All @@ -131,7 +131,7 @@ func (c *connWrapper) Read(buf []byte) (int, error) {
c.netx.Logger.InfoContext(
c.ctx,
"readDone",
slog.Int("count", count),
slog.Int("ioBytesCount", count),
slog.Any("err", err),
slog.String("localAddr", c.laddr),
slog.String("protocol", c.protocol),
Expand Down Expand Up @@ -169,7 +169,7 @@ func (c *connWrapper) Write(data []byte) (n int, err error) {
c.netx.Logger.InfoContext(
c.ctx,
"writeStart",
slog.Int("count", len(data)),
slog.Int("ioBufferSize", len(data)),
slog.String("localAddr", c.laddr),
slog.String("protocol", c.protocol),
slog.String("remoteAddr", c.raddr),
Expand All @@ -183,7 +183,7 @@ func (c *connWrapper) Write(data []byte) (n int, err error) {
c.netx.Logger.InfoContext(
c.ctx,
"writeDone",
slog.Int("count", count),
slog.Int("ioBytesCount", count),
slog.Any("err", err),
slog.String("localAddr", c.laddr),
slog.String("protocol", c.protocol),
Expand Down
6 changes: 3 additions & 3 deletions netcore/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (nx *Network) emitLookupHostStart(ctx context.Context, domain string) time.
nx.Logger.InfoContext(
ctx,
"lookupHostStart",
slog.String("domain", domain),
slog.String("dnsLookupDomain", domain),
slog.Time("t", t0),
)
}
Expand All @@ -94,8 +94,8 @@ func (nx *Network) emitLookupHostDone(ctx context.Context,
nx.Logger.InfoContext(
ctx,
"lookupHostDone",
slog.String("domain", domain),
slog.Any("addrs", addrs),
slog.String("dnsLookupDomain", domain),
slog.Any("dnsResolvedAddrs", addrs),
slog.Any("err", err),
slog.Time("t0", t0),
slog.Time("t", nx.timeNow()),
Expand Down

0 comments on commit 36619f9

Please sign in to comment.