Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishapi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishapi
Commits
90c90809
Commit
90c90809
authored
Aug 07, 2018
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor the name Transaction -> Tx, for idiomatic Go terseness.
parent
cb17b3e8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
15 deletions
+16
-15
log.go
pkg/log/log.go
+14
-13
log_test.go
pkg/log/log_test.go
+2
-2
No files found.
pkg/log/log.go
View file @
90c90809
...
...
@@ -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
// T
ransaction objects returned by Read() operations, and form the
//
bulk of log
data.
// T
x 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 T
ransaction is a collection of related log records, typically as
// t
he log of a client or backend request and response. Transactions
//
may also include data unrelated to requests and responses, such a
s
// backend health checks.
// A T
x for "transaction" is a collection of related log records,
// t
ypically as the log of a client or backend request and
//
response. Transactions may also include data unrelated to request
s
//
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
T
ransaction
struct
{
type
T
x
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
[]
*
T
ransaction
var
gtxn
[]
*
T
x
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
(
T
ransaction
)
tx
:=
new
(
T
x
)
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 T
ransaction
//
objects. The
second argument of type *Status is nil in this case.
// passed to the callback as a slice of pointers to T
x 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
([]
*
T
ransaction
,
*
Status
)
bool
type
ReadCB
func
([]
*
T
x
,
*
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 []*T
ransaction
, rdstatus *Status) bool {
// cb := func(txGrp []*T
x
, rdstatus *Status) bool {
// // if the status is not nil, send it on the status channel
// if rdstatus != nil {
// statusChan <- *rdstatus
...
...
pkg/log/log_test.go
View file @
90c90809
...
...
@@ -152,7 +152,7 @@ TX:
}
func
TestDefaultRead
(
t
*
testing
.
T
)
{
var
txGrps
[][]
*
T
ransaction
var
txGrps
[][]
*
T
x
expTxn
,
err
:=
scrapeLog
(
vxidLog
)
if
err
!=
nil
{
...
...
@@ -167,7 +167,7 @@ func TestDefaultRead(t *testing.T) {
}
statusChan
:=
make
(
chan
Status
)
cb
:=
func
(
txGrp
[]
*
T
ransaction
,
rdstatus
*
Status
)
bool
{
cb
:=
func
(
txGrp
[]
*
T
x
,
rdstatus
*
Status
)
bool
{
if
rdstatus
!=
nil
{
statusChan
<-
*
rdstatus
return
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment