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
5877724c
Commit
5877724c
authored
Aug 11, 2018
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass a slice of Tx (not a slice of pointers) to the read callback.
parent
5dd078e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
17 deletions
+15
-17
e2e_test.go
pkg/log/e2e_test.go
+7
-9
log.go
pkg/log/log.go
+6
-6
log_test.go
pkg/log/log_test.go
+2
-2
No files found.
pkg/log/e2e_test.go
View file @
5877724c
...
...
@@ -230,8 +230,7 @@ func checkRec(t *testing.T, rec Record, expRec expRec) {
}
}
func
checkTx
(
t
*
testing
.
T
,
txp
*
Tx
,
expTxLen
expTxLen
)
{
tx
:=
*
txp
func
checkTx
(
t
*
testing
.
T
,
tx
Tx
,
expTxLen
expTxLen
)
{
expTx
:=
expTxLen
.
tx
if
expTx
.
typ
!=
txTypeUndef
&&
expTx
.
typ
!=
tx
.
Type
{
t
.
Errorf
(
"tx.Type want=%v got=%v"
,
expTx
.
typ
,
tx
.
Type
)
...
...
@@ -306,7 +305,7 @@ func checkTx(t *testing.T, txp *Tx, expTxLen expTxLen) {
}
}
func
checkTxGrp
(
t
*
testing
.
T
,
txGrp
[]
*
Tx
,
expTxGrp
expTxGrp
)
{
func
checkTxGrp
(
t
*
testing
.
T
,
txGrp
[]
Tx
,
expTxGrp
expTxGrp
)
{
if
expTxGrp
.
expTx
!=
undefLen
&&
len
(
txGrp
)
!=
expTxGrp
.
expTx
{
t
.
Fatalf
(
"number of tx in group got=%v want=%v"
,
len
(
txGrp
),
expTxGrp
.
expTx
)
...
...
@@ -317,7 +316,7 @@ func checkTxGrp(t *testing.T, txGrp []*Tx, expTxGrp expTxGrp) {
}
}
func
checkTxGrps
(
t
*
testing
.
T
,
txGrps
[][]
*
Tx
,
expTxGrps
[]
expTxGrp
)
{
func
checkTxGrps
(
t
*
testing
.
T
,
txGrps
[][]
Tx
,
expTxGrps
[]
expTxGrp
)
{
if
len
(
txGrps
)
!=
len
(
expTxGrps
)
{
t
.
Fatalf
(
"number of tx groups got=%v want=%v"
,
len
(
txGrps
),
len
(
expTxGrps
))
...
...
@@ -451,8 +450,8 @@ func TestE2EDefaultRead(t *testing.T) {
}
statusChan
:=
make
(
chan
Status
)
txChan
:=
make
(
chan
[]
*
Tx
,
100
)
cb
:=
func
(
txGrp
[]
*
Tx
,
rdstatus
Status
)
bool
{
txChan
:=
make
(
chan
[]
Tx
,
100
)
cb
:=
func
(
txGrp
[]
Tx
,
rdstatus
Status
)
bool
{
switch
rdstatus
{
case
More
:
txChan
<-
txGrp
...
...
@@ -479,7 +478,7 @@ func TestE2EDefaultRead(t *testing.T) {
t
.
Fatal
(
"/uncacheable Response"
,
err
)
}
var
txGrps
[][]
*
Tx
var
txGrps
[][]
Tx
TX
:
for
{
select
{
...
...
@@ -497,8 +496,7 @@ TX:
checkTxGrps
(
t
,
txGrps
,
expDefaultRead
)
for
_
,
txGrp
:=
range
txGrps
{
txp
:=
txGrp
[
0
]
tx
:=
*
txp
tx
:=
txGrp
[
0
]
if
tx
.
Type
==
BeReq
{
checkBereq
(
t
,
tx
,
*
req
)
}
...
...
pkg/log/log.go
View file @
5877724c
...
...
@@ -511,7 +511,7 @@ func quote(s string) string {
//export publish
func
publish
(
trans
unsafe
.
Pointer
,
priv
unsafe
.
Pointer
)
C
.
int
{
var
gtxn
[]
*
Tx
var
gtxn
[]
Tx
txn
:=
(
*
[
1
<<
30
]
*
C
.
struct_VSL_transaction
)(
unsafe
.
Pointer
(
trans
))
if
txn
[
0
]
==
nil
{
return
0
...
...
@@ -523,8 +523,8 @@ func publish(trans unsafe.Pointer, priv unsafe.Pointer) C.int {
panic
(
"unmapped transaction channel"
)
}
for
i
:=
0
;
txn
[
i
]
!=
nil
;
i
++
{
var
tx
Tx
vtx
:=
txn
[
i
]
tx
:=
new
(
Tx
)
tx
.
Type
=
TxType
(
C
.
txtype
(
vtx
))
tx
.
VXID
=
uint32
(
vtx
.
vxid
)
tx
.
ParentVXID
=
uint32
(
vtx
.
vxid_parent
)
...
...
@@ -645,8 +645,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 Tx objects. The
//
second
argument of type Status is log.More in this case.
// passed to the callback as a slice of
Tx objects. The second
// argument of type Status is log.More in this case.
//
// When the log read encounters an error or end condition (end of log
// or end of file), then it passes a Status in the second argument to
...
...
@@ -658,7 +658,7 @@ func (status Status) Error() string {
// more time with the Status set to Stopped, and nil for the
// transaction slice, and the goroutine initiated by the Read method
// is stopped.
type
ReadCB
func
([]
*
Tx
,
Status
)
bool
type
ReadCB
func
([]
Tx
,
Status
)
bool
// ContinueHandler is the type of a function that is passed to the
// Read method. It is executed when the end-of-log condition is
...
...
@@ -710,7 +710,7 @@ func defaultContinue() bool {
// statusChan := make(chan Status)
//
// // this callback will be passed to the Read method
// cb := func(txGrp []
*
Tx, rdstatus Status) bool {
// cb := func(txGrp []Tx, rdstatus Status) bool {
// // if the status is not log.More, send it on the status channel
// if rdstatus != log.More {
// statusChan <- rdstatus
...
...
pkg/log/log_test.go
View file @
5877724c
...
...
@@ -184,7 +184,7 @@ TX:
}
func
TestDefaultRead
(
t
*
testing
.
T
)
{
var
txGrps
[][]
*
Tx
var
txGrps
[][]
Tx
expTxn
,
err
:=
scrapeLog
(
vxidLog
)
if
err
!=
nil
{
...
...
@@ -199,7 +199,7 @@ func TestDefaultRead(t *testing.T) {
}
statusChan
:=
make
(
chan
Status
)
cb
:=
func
(
txGrp
[]
*
Tx
,
rdstatus
Status
)
bool
{
cb
:=
func
(
txGrp
[]
Tx
,
rdstatus
Status
)
bool
{
if
rdstatus
!=
More
{
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