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