Skip to content

Commit 8018189

Browse files
Support "stand-alone" mode for uuid-annotator (conditionally tcpinfo eventsocket) (#42)
* Start the event socket conditionally * Make loading siteinfo and starting the tcp-info handler conditional * Add stand-alone usage example to README.md
1 parent 24588ab commit 8018189

File tree

2 files changed

+38
-17
lines changed

2 files changed

+38
-17
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,21 @@ tcp-info, packet-headers, traceroute-caller, and DISCO. It represents our one
5151
chance to annotate UUIDs with metadata. As such, the health of the experiment
5252
service should depend on the health of the UUID annotation service, just like it
5353
should depend on the other core services.
54+
55+
## Usage
56+
57+
### Stand-alone
58+
59+
If only the local ipservice socket is needed to provide annotations for specific
60+
IPs, the uuid-annotator may be run in a "stand-alone" mode. This mode does not
61+
require the tcp-info `-tcpinfo.eventsocket`, `-siteinfo.url`, or `-datadir`
62+
flags.
63+
64+
```sh
65+
docker build -t local-annotator .
66+
docker run -v $PWD/testdata:/testdata -it local-annotator \
67+
-ipservice.sock=/local/uuid-annotator.sock \
68+
-maxmind.url=file:///testdata/GeoLite2-City-real.tar.gz \
69+
-routeview-v4.url=file:///testdata/RouteViewIPv4.pfx2as.gz \
70+
-routeview-v6.url=file:///testdata/RouteViewIPv6.pfx2as.gz
71+
```

main.go

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ func main() {
100100
rtx.Must(err, "Could not load AS names URL")
101101
asn := asnannotator.New(mainCtx, p4, p6, asnames, localIPs)
102102

103-
js, err := content.FromURL(mainCtx, siteinfo.URL)
104-
rtx.Must(err, "Could not load siteinfo URL")
105-
site := siteannotator.New(mainCtx, *hostname, js, localIPs)
106-
107103
// Reload the IP annotation config on a randomized schedule.
108104
wg.Add(1)
109105
go func() {
@@ -121,20 +117,27 @@ func main() {
121117
wg.Done()
122118
}()
123119

124-
// Generate .json files for every UUID discovered.
125-
h := handler.New(*datadir, *eventbuffersize, []annotator.Annotator{geo, asn, site})
126-
wg.Add(1)
127-
go func() {
128-
h.ProcessIncomingRequests(mainCtx)
129-
wg.Done()
130-
}()
120+
if *eventsocket.Filename != "" {
121+
// Load the siteinfo annotations for "site" specific metadata.
122+
js, err := content.FromURL(mainCtx, siteinfo.URL)
123+
rtx.Must(err, "Could not load siteinfo URL")
124+
site := siteannotator.New(mainCtx, *hostname, js, localIPs)
131125

132-
// Listen to the event socket to find out about new UUIDs and then process them.
133-
wg.Add(1)
134-
go func() {
135-
eventsocket.MustRun(mainCtx, *eventsocket.Filename, h)
136-
wg.Done()
137-
}()
126+
// Generate .json files for every UUID discovered.
127+
h := handler.New(*datadir, *eventbuffersize, []annotator.Annotator{geo, asn, site})
128+
wg.Add(1)
129+
go func() {
130+
h.ProcessIncomingRequests(mainCtx)
131+
wg.Done()
132+
}()
133+
134+
// Listen to the event socket to find out about new UUIDs and then process them.
135+
wg.Add(1)
136+
go func() {
137+
eventsocket.MustRun(mainCtx, *eventsocket.Filename, h)
138+
wg.Done()
139+
}()
140+
}
138141

139142
// Set up the local service to serve IP annotations as a local service on a
140143
// local unix-domain socket.

0 commit comments

Comments
 (0)