Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
c34361dc
Commit
c34361dc
authored
Jan 18, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f3eafccb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
go/internal/xcontext/task/task.go
go/internal/xcontext/task/task.go
+9
-6
No files found.
go/internal/xcontext/task/task.go
View file @
c34361dc
...
@@ -29,15 +29,18 @@ import (
...
@@ -29,15 +29,18 @@ import (
// Task represents currently running operation.
// Task represents currently running operation.
type
Task
struct
{
type
Task
struct
{
P
arent
*
Task
p
arent
*
Task
N
ame
string
n
ame
string
}
}
func
(
t
*
Task
)
Parent
()
*
Task
{
return
t
.
parent
}
func
(
t
*
Task
)
Name
()
string
{
return
t
.
name
}
type
taskKey
struct
{}
type
taskKey
struct
{}
// Running creates new task and returns new context with that task set to current.
// Running creates new task and returns new context with that task set to current.
func
Running
(
ctx
context
.
Context
,
name
string
)
context
.
Context
{
func
Running
(
ctx
context
.
Context
,
name
string
)
context
.
Context
{
return
context
.
WithValue
(
ctx
,
taskKey
{},
&
Task
{
Parent
:
Current
(
ctx
),
N
ame
:
name
})
return
context
.
WithValue
(
ctx
,
taskKey
{},
&
Task
{
parent
:
Current
(
ctx
),
n
ame
:
name
})
}
}
// Runningf is Running cousin with formatting support.
// Runningf is Running cousin with formatting support.
...
@@ -68,7 +71,7 @@ func ErrContext(errp *error, ctx context.Context) {
...
@@ -68,7 +71,7 @@ func ErrContext(errp *error, ctx context.Context) {
if
task
==
nil
{
if
task
==
nil
{
return
return
}
}
xerr
.
Context
(
errp
,
task
.
N
ame
)
xerr
.
Context
(
errp
,
task
.
n
ame
)
}
}
// String returns string representing whole operational stack.
// String returns string representing whole operational stack.
...
@@ -82,10 +85,10 @@ func (t *Task) String() string {
...
@@ -82,10 +85,10 @@ func (t *Task) String() string {
return
""
return
""
}
}
prefix
:=
t
.
P
arent
.
String
()
prefix
:=
t
.
p
arent
.
String
()
if
prefix
!=
""
{
if
prefix
!=
""
{
prefix
+=
": "
prefix
+=
": "
}
}
return
prefix
+
t
.
N
ame
return
prefix
+
t
.
n
ame
}
}
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