Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
jacobsa-fuse
Commits
66796316
Commit
66796316
authored
May 01, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored how op descriptions work.
parent
a7de8c87
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
fuseops/common_op.go
fuseops/common_op.go
+14
-9
fuseops/convert.go
fuseops/convert.go
+1
-2
No files found.
fuseops/common_op.go
View file @
66796316
...
...
@@ -38,7 +38,11 @@ var fTraceByPID = flag.Bool(
// A helper for embedding common behavior.
type
commonOp
struct
{
opType
string
// The op in which this struct is embedded, and a short description of it.
op
Op
opDesc
string
// The underlying bazilfuse request for this op.
bazilReq
bazilfuse
.
Request
// Dependencies.
...
...
@@ -50,8 +54,8 @@ type commonOp struct {
report
reqtrace
.
ReportFunc
}
func
describeOp
Type
(
t
reflect
.
Type
)
(
desc
string
)
{
name
:=
t
.
String
()
func
describeOp
(
op
Op
)
(
desc
string
)
{
name
:=
reflect
.
TypeOf
(
op
)
.
String
()
// The usual case: a string that looks like "*fuseops.GetInodeAttributesOp".
const
prefix
=
"*fuseops."
...
...
@@ -62,7 +66,7 @@ func describeOpType(t reflect.Type) (desc string) {
}
// Otherwise, it's not clear what to do.
desc
=
t
.
String
()
desc
=
name
return
}
...
...
@@ -147,7 +151,7 @@ func (o *commonOp) maybeTraceByPID(
func
(
o
*
commonOp
)
init
(
ctx
context
.
Context
,
op
Type
reflect
.
Type
,
op
Op
,
bazilReq
bazilfuse
.
Request
,
log
func
(
int
,
string
,
...
interface
{}),
opsInFlight
*
sync
.
WaitGroup
)
{
...
...
@@ -155,13 +159,14 @@ func (o *commonOp) init(
ctx
=
o
.
maybeTraceByPID
(
ctx
,
int
(
bazilReq
.
Hdr
()
.
Pid
))
// Initialize basic fields.
o
.
opType
=
describeOpType
(
opType
)
o
.
op
=
op
o
.
opDesc
=
describeOp
(
op
)
o
.
bazilReq
=
bazilReq
o
.
log
=
log
o
.
opsInFlight
=
opsInFlight
// Set up a trace span for this op.
o
.
ctx
,
o
.
report
=
reqtrace
.
StartSpan
(
ctx
,
o
.
op
Type
)
o
.
ctx
,
o
.
report
=
reqtrace
.
StartSpan
(
ctx
,
o
.
op
Desc
)
}
func
(
o
*
commonOp
)
Header
()
OpHeader
{
...
...
@@ -190,7 +195,7 @@ func (o *commonOp) respondErr(err error) {
o
.
Logf
(
"-> (%s) error: %v"
,
o
.
op
Type
,
o
.
op
Desc
,
err
)
o
.
bazilReq
.
RespondError
(
err
)
...
...
@@ -210,7 +215,7 @@ func (o *commonOp) respond(resp interface{}) {
// Special case: handle successful ops with no response struct.
if
resp
==
nil
{
o
.
Logf
(
"-> (%s) OK"
,
o
.
op
Type
)
o
.
Logf
(
"-> (%s) OK"
,
o
.
op
Desc
)
respond
.
Call
([]
reflect
.
Value
{})
return
}
...
...
fuseops/convert.go
View file @
66796316
...
...
@@ -15,7 +15,6 @@
package
fuseops
import
(
"reflect"
"sync"
"time"
...
...
@@ -216,7 +215,7 @@ func Convert(
return
}
co
.
init
(
parentCtx
,
reflect
.
TypeOf
(
o
)
,
r
,
logForOp
,
opsInFlight
)
co
.
init
(
parentCtx
,
o
,
r
,
logForOp
,
opsInFlight
)
return
}
...
...
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