Commit 90c90809 authored by Geoff Simmons's avatar Geoff Simmons

Refactor the name Transaction -> Tx, for idiomatic Go terseness.

parent cb17b3e8
...@@ -202,10 +202,11 @@ var ( ...@@ -202,10 +202,11 @@ var (
// A Record in the Varnish log, corresponding to a line of output from // A Record in the Varnish log, corresponding to a line of output from
// the varnishlog utility. Instances of this type are contained in the // the varnishlog utility. Instances of this type are contained in the
// Transaction objects returned by Read() operations, and form the // Tx objects returned by Read() operations, and form the bulk of log
// bulk of log data. // data.
// //
// The contents and format of log records are described in vsl(7): // The contents and format of log records are described in vsl(7):
//
// https://varnish-cache.org/docs/trunk/reference/vsl.html // https://varnish-cache.org/docs/trunk/reference/vsl.html
type Record struct { type Record struct {
// Indicates whether this record is part of a client or // Indicates whether this record is part of a client or
...@@ -233,10 +234,10 @@ type Record struct { ...@@ -233,10 +234,10 @@ type Record struct {
Payload string Payload string
} }
// A Transaction is a collection of related log records, typically as // A Tx for "transaction" is a collection of related log records,
// the log of a client or backend request and response. Transactions // typically as the log of a client or backend request and
// may also include data unrelated to requests and responses, such as // response. Transactions may also include data unrelated to requests
// backend health checks. // and responses, such as backend health checks.
// //
// Transactions are read from the log in groups, according to the // Transactions are read from the log in groups, according to the
// Grouping selected for the log client, corresponding to the grouping // Grouping selected for the log client, corresponding to the grouping
...@@ -249,7 +250,7 @@ type Record struct { ...@@ -249,7 +250,7 @@ type Record struct {
// The depth of nesting in a hierarchy is represented by a // The depth of nesting in a hierarchy is represented by a
// transaction's Level property. Levels start at level 1, except for // transaction's Level property. Levels start at level 1, except for
// raw transactions, which always have level 0. // raw transactions, which always have level 0.
type Transaction struct { type Tx struct {
// Whether this is the log of a client request/response, // Whether this is the log of a client request/response,
// backend request/response, session and so forth. // backend request/response, session and so forth.
Type TxType Type TxType
...@@ -357,7 +358,7 @@ func quote(s string) string { ...@@ -357,7 +358,7 @@ func quote(s string) string {
//export publish //export publish
func publish(trans unsafe.Pointer, priv unsafe.Pointer) C.int { func publish(trans unsafe.Pointer, priv unsafe.Pointer) C.int {
var gtxn []*Transaction var gtxn []*Tx
txn := (*[1 << 30]*C.struct_VSL_transaction)(unsafe.Pointer(trans)) txn := (*[1 << 30]*C.struct_VSL_transaction)(unsafe.Pointer(trans))
if txn[0] == nil { if txn[0] == nil {
return 0 return 0
...@@ -370,7 +371,7 @@ func publish(trans unsafe.Pointer, priv unsafe.Pointer) C.int { ...@@ -370,7 +371,7 @@ func publish(trans unsafe.Pointer, priv unsafe.Pointer) C.int {
} }
for i := 0; txn[i] != nil; i++ { for i := 0; txn[i] != nil; i++ {
vtx := txn[i] vtx := txn[i]
tx := new(Transaction) tx := new(Tx)
tx.Type = TxType(C.txtype(vtx)) tx.Type = TxType(C.txtype(vtx))
tx.VXID = uint32(vtx.vxid) tx.VXID = uint32(vtx.vxid)
tx.ParentVXID = uint32(vtx.vxid_parent) tx.ParentVXID = uint32(vtx.vxid_parent)
...@@ -490,8 +491,8 @@ func (status Status) Error() string { ...@@ -490,8 +491,8 @@ func (status Status) Error() string {
// read. // read.
// //
// When the log read has aggregated a group of transactions, they are // When the log read has aggregated a group of transactions, they are
// passed to the callback as a slice of pointers to Transaction // passed to the callback as a slice of pointers to Tx objects. The
// objects. The second argument of type *Status is nil in this case. // second argument of type *Status is nil in this case.
// //
// When the log read encounters an error or end condition (end of log // When the log read encounters an error or end condition (end of log
// or end of file), then it passes a pointer to Status in the second // or end of file), then it passes a pointer to Status in the second
...@@ -503,7 +504,7 @@ func (status Status) Error() string { ...@@ -503,7 +504,7 @@ func (status Status) Error() string {
// more time with a pointer to Status set to Stopped, and nil for the // more time with a pointer to Status set to Stopped, and nil for the
// transaction slice, and the goroutine initiated by the Read method // transaction slice, and the goroutine initiated by the Read method
// is stopped. // is stopped.
type ReadCB func([]*Transaction, *Status) bool type ReadCB func([]*Tx, *Status) bool
// Read starts a goroutine that reads from the currently attached log // Read starts a goroutine that reads from the currently attached log
// source, and invokes the callback cb, as documented for ReadCB. // source, and invokes the callback cb, as documented for ReadCB.
...@@ -517,7 +518,7 @@ type ReadCB func([]*Transaction, *Status) bool ...@@ -517,7 +518,7 @@ type ReadCB func([]*Transaction, *Status) bool
// statusChan := make(chan *Status) // statusChan := make(chan *Status)
// //
// // this callback will be passed to the Read method // // this callback will be passed to the Read method
// cb := func(txGrp []*Transaction, rdstatus *Status) bool { // cb := func(txGrp []*Tx, rdstatus *Status) bool {
// // if the status is not nil, send it on the status channel // // if the status is not nil, send it on the status channel
// if rdstatus != nil { // if rdstatus != nil {
// statusChan <- *rdstatus // statusChan <- *rdstatus
......
...@@ -152,7 +152,7 @@ TX: ...@@ -152,7 +152,7 @@ TX:
} }
func TestDefaultRead(t *testing.T) { func TestDefaultRead(t *testing.T) {
var txGrps [][]*Transaction var txGrps [][]*Tx
expTxn, err := scrapeLog(vxidLog) expTxn, err := scrapeLog(vxidLog)
if err != nil { if err != nil {
...@@ -167,7 +167,7 @@ func TestDefaultRead(t *testing.T) { ...@@ -167,7 +167,7 @@ func TestDefaultRead(t *testing.T) {
} }
statusChan := make(chan Status) statusChan := make(chan Status)
cb := func(txGrp []*Transaction, rdstatus *Status) bool { cb := func(txGrp []*Tx, rdstatus *Status) bool {
if rdstatus != nil { if rdstatus != nil {
statusChan <- *rdstatus statusChan <- *rdstatus
return false return false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment