Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
d74c9d41
Commit
d74c9d41
authored
Aug 10, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
95d0183c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
go/neo/server/util.go
go/neo/server/util.go
+2
-2
go/xcommon/task/task.go
go/xcommon/task/task.go
+5
-5
No files found.
go/neo/server/util.go
View file @
d74c9d41
...
@@ -28,7 +28,7 @@ import (
...
@@ -28,7 +28,7 @@ import (
"lab.nexedi.com/kirr/neo/go/xcommon/log"
"lab.nexedi.com/kirr/neo/go/xcommon/log"
)
)
// running is syntatic sugar to push new task to operational stack, log it and
// running is synta
c
tic sugar to push new task to operational stack, log it and
// adjust error return with task prefix.
// adjust error return with task prefix.
//
//
// use like this:
// use like this:
...
@@ -38,7 +38,7 @@ func running(ctxp *context.Context, name string) func(*error) {
...
@@ -38,7 +38,7 @@ func running(ctxp *context.Context, name string) func(*error) {
return
_running
(
ctxp
,
name
)
return
_running
(
ctxp
,
name
)
}
}
// runningf is running cousin
g
with formatting support
// runningf is running cousin with formatting support
func
runningf
(
ctxp
*
context
.
Context
,
format
string
,
argv
...
interface
{})
func
(
*
error
)
{
func
runningf
(
ctxp
*
context
.
Context
,
format
string
,
argv
...
interface
{})
func
(
*
error
)
{
return
_running
(
ctxp
,
fmt
.
Sprintf
(
format
,
argv
...
))
return
_running
(
ctxp
,
fmt
.
Sprintf
(
format
,
argv
...
))
}
}
...
...
go/xcommon/task/task.go
View file @
d74c9d41
...
@@ -40,7 +40,7 @@ func Running(ctx context.Context, name string) context.Context {
...
@@ -40,7 +40,7 @@ func Running(ctx context.Context, name string) context.Context {
return
context
.
WithValue
(
ctx
,
taskKey
{},
&
Task
{
Parent
:
Current
(
ctx
),
Name
:
name
})
return
context
.
WithValue
(
ctx
,
taskKey
{},
&
Task
{
Parent
:
Current
(
ctx
),
Name
:
name
})
}
}
// Runningf is Running cousin
g
with formatting support
// Runningf is Running cousin with formatting support
func
Runningf
(
ctx
context
.
Context
,
format
string
,
argv
...
interface
{})
context
.
Context
{
func
Runningf
(
ctx
context
.
Context
,
format
string
,
argv
...
interface
{})
context
.
Context
{
return
Running
(
ctx
,
fmt
.
Sprintf
(
format
,
argv
...
))
return
Running
(
ctx
,
fmt
.
Sprintf
(
format
,
argv
...
))
}
}
...
@@ -53,14 +53,14 @@ func Current(ctx context.Context) *Task {
...
@@ -53,14 +53,14 @@ func Current(ctx context.Context) *Task {
}
}
// ErrContext adds current task name to error on error return.
// ErrContext adds current task name to error on error return.
//
t
o work as intended it should be called under defer like this:
//
T
o work as intended it should be called under defer like this:
//
//
// func myfunc(ctx, ...) (..., err error) {
// func myfunc(ctx, ...) (..., err error) {
// ctx = task.Running("doing something")
// ctx = task.Running("doing something")
// defer task.ErrContext(&err, ctx)
// defer task.ErrContext(&err, ctx)
// ...
// ...
//
//
// Please see lab.nexedi.com/kirr/go123/xerr.Context for semantic details
// Please see lab.nexedi.com/kirr/go123/xerr.Context for semantic details
.
func
ErrContext
(
errp
*
error
,
ctx
context
.
Context
)
{
func
ErrContext
(
errp
*
error
,
ctx
context
.
Context
)
{
task
:=
Current
(
ctx
)
task
:=
Current
(
ctx
)
if
task
==
nil
{
if
task
==
nil
{
...
@@ -72,9 +72,9 @@ func ErrContext(errp *error, ctx context.Context) {
...
@@ -72,9 +72,9 @@ func ErrContext(errp *error, ctx context.Context) {
// String returns string representing whole operational stack.
// String returns string representing whole operational stack.
//
//
// For example if task "c" is running under task "b" which in turn is running
// For example if task "c" is running under task "b" which in turn is running
// under task "a" - the operational stack will be "a: b: c"
// under task "a" - the operational stack will be "a: b: c"
.
//
//
// nil Task is represented as ""
// nil Task is represented as ""
.
func
(
t
*
Task
)
String
()
string
{
func
(
t
*
Task
)
String
()
string
{
if
t
==
nil
{
if
t
==
nil
{
return
""
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