GWR provides on demand access to operational data:
GWR is currently in beta devolopment:
GWR exposes a dual HTTP and RESP (Redis Protocol) interface. Integrators may specify the port, the example below uses 4040.
The following examples are against a running instance of example_server/
.
Example for http:
$ curl localhost:4040/meta/nouns
- /meta/nouns formats: <no value>
- /request_log formats: <no value>
- /response_log formats: <no value>
$ curl -X WATCH localhost:4040/request_log&
$ curl -X WATCH localhost:4040/response_log&
$ curl localhost:8080/foo
404 page not found # this is the normal curl output
GET /foo # this comes from the first watch-curl
404 19 text/plain; charset=utf-8 # this comes from the first watch-curl
$ redis-cli -p 4040 ls # this is a convenience alias for "get /meta/nouns"
1) - /meta/nouns formats: <no value>
2) - /request_log formats: <no value>
3) - /response_log formats: <no value>
$ redis-cli -p 4040 monitor /request_log text /response_log text&
OK
$ curl localhost:8080/bar
404 page not found # this is the curl output
/request_log> GET /bar # this is from redis-cli
/response_log> 404 19 text/plain; charset=utf-8 # so is this, ordering not guaranteed
To add gwr to a program, all you need to do is call:
gwrProto.ListenAndServe(":4040", nil)
This hosts dual protocol HTTP and RESP server on port 4040.
To define a data source, the easiest way is to implement the
gwr.GenericDataSource
interface.
TODO: example
For now see example_server/req_logger.go
and example_server/res_logger.go
Should work by:
$ go run example_server/*.go
The example server hosts a dummy 404-ing web server on port 8080
and exposes
a request and response log GWR noun. The HTTP and Resp usage examples above
are against it.