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
d31b0cbd
Commit
d31b0cbd
authored
May 01, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored op descriptions again.
parent
6868642c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
23 deletions
+24
-23
fuseops/common_op.go
fuseops/common_op.go
+21
-23
fuseops/ops.go
fuseops/ops.go
+3
-0
No files found.
fuseops/common_op.go
View file @
d31b0cbd
...
...
@@ -39,8 +39,7 @@ var fTraceByPID = flag.Bool(
// A helper for embedding common behavior.
type
commonOp
struct
{
// The op in which this struct is embedded, and a short description of it.
op
Op
opDesc
string
op
Op
// The underlying bazilfuse request for this op.
bazilReq
bazilfuse
.
Request
...
...
@@ -54,23 +53,6 @@ type commonOp struct {
report
reqtrace
.
ReportFunc
}
func
describeOp
(
op
Op
)
(
desc
string
)
{
name
:=
reflect
.
TypeOf
(
op
)
.
String
()
// The usual case: a string that looks like "*fuseops.GetInodeAttributesOp".
const
prefix
=
"*fuseops."
const
suffix
=
"Op"
if
strings
.
HasPrefix
(
name
,
prefix
)
&&
strings
.
HasSuffix
(
name
,
suffix
)
{
desc
=
name
[
len
(
prefix
)
:
len
(
name
)
-
len
(
suffix
)]
return
}
// Otherwise, it's not clear what to do.
desc
=
name
return
}
var
gPIDMapMu
sync
.
Mutex
// A map from PID to a traced context for that PID.
...
...
@@ -149,6 +131,23 @@ func (o *commonOp) maybeTraceByPID(
return
}
func
(
o
*
commonOp
)
ShortDesc
()
(
desc
string
)
{
name
:=
reflect
.
TypeOf
(
o
.
op
)
.
String
()
// The usual case: a string that looks like "*fuseops.GetInodeAttributesOp".
const
prefix
=
"*fuseops."
const
suffix
=
"Op"
if
strings
.
HasPrefix
(
name
,
prefix
)
&&
strings
.
HasSuffix
(
name
,
suffix
)
{
desc
=
name
[
len
(
prefix
)
:
len
(
name
)
-
len
(
suffix
)]
return
}
// Otherwise, it's not clear what to do.
desc
=
name
return
}
func
(
o
*
commonOp
)
init
(
ctx
context
.
Context
,
op
Op
,
...
...
@@ -160,13 +159,12 @@ func (o *commonOp) init(
// Initialize basic fields.
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
.
opDesc
)
o
.
ctx
,
o
.
report
=
reqtrace
.
StartSpan
(
ctx
,
o
.
ShortDesc
()
)
}
func
(
o
*
commonOp
)
Header
()
OpHeader
{
...
...
@@ -195,7 +193,7 @@ func (o *commonOp) respondErr(err error) {
o
.
Logf
(
"-> (%s) error: %v"
,
o
.
opDesc
,
o
.
ShortDesc
()
,
err
)
o
.
bazilReq
.
RespondError
(
err
)
...
...
@@ -215,7 +213,7 @@ func (o *commonOp) respond(resp interface{}) {
// Special case: handle successful ops with no response struct.
if
resp
==
nil
{
o
.
Logf
(
"-> (%s) OK"
,
o
.
opDesc
)
o
.
Logf
(
"-> (%s) OK"
,
o
.
ShortDesc
()
)
respond
.
Call
([]
reflect
.
Value
{})
return
}
...
...
fuseops/ops.go
View file @
d31b0cbd
...
...
@@ -29,6 +29,9 @@ import (
// to find particular concrete types, responding with fuse.ENOSYS if a type is
// not supported.
type
Op
interface
{
// A short description of the op, to be used in logging.
ShortDesc
()
string
// Return the fields common to all operations.
Header
()
OpHeader
...
...
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