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
fce7640c
Commit
fce7640c
authored
Jan 15, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
85fdae69
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
27 deletions
+21
-27
go/internal/task/task.go
go/internal/task/task.go
+21
-27
No files found.
go/internal/task/task.go
View file @
fce7640c
...
@@ -21,11 +21,11 @@
...
@@ -21,11 +21,11 @@
package
task
package
task
import
(
import
(
"context"
"context"
"fmt"
"fmt"
taskctx
"lab.nexedi.com/kirr/neo/go/internal/xcontext/task"
taskctx
"lab.nexedi.com/kirr/neo/go/internal/xcontext/task"
"lab.nexedi.com/kirr/neo/go/internal/log"
"lab.nexedi.com/kirr/neo/go/internal/log"
)
)
// Running is syntactic sugar to push new task to operational stack, log it and
// Running is syntactic sugar to push new task to operational stack, log it and
...
@@ -35,34 +35,28 @@ import (
...
@@ -35,34 +35,28 @@ import (
//
//
// defer task.Running(&ctx, "my task")(&err)
// defer task.Running(&ctx, "my task")(&err)
func
Running
(
ctxp
*
context
.
Context
,
name
string
)
func
(
*
error
)
{
func
Running
(
ctxp
*
context
.
Context
,
name
string
)
func
(
*
error
)
{
return
running
(
ctxp
,
name
)
return
running
(
ctxp
,
name
)
}
}
// Runningf is Running cousin 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
...
))
}
}
func
running
(
ctxp
*
context
.
Context
,
name
string
)
func
(
*
error
)
{
func
running
(
ctxp
*
context
.
Context
,
name
string
)
func
(
*
error
)
{
ctx
:=
taskctx
.
Running
(
*
ctxp
,
name
)
ctx
:=
taskctx
.
Running
(
*
ctxp
,
name
)
*
ctxp
=
ctx
*
ctxp
=
ctx
log
.
Depth
(
2
)
.
Info
(
ctx
,
"start"
)
// XXX log -> trace
log
.
Depth
(
2
)
.
Info
(
ctx
,
"["
)
// XXX log -> trace, don't put ":" before "["
return
func
(
errp
*
error
)
{
return
func
(
errp
*
error
)
{
if
*
errp
!=
nil
{
err
:=
""
// XXX is it good idea to log to error here? (not in above layer)
if
e
:=
*
errp
;
e
!=
nil
{
// XXX what is error here could be not so error above
err
=
fmt
.
Sprintf
(
" (%s)"
,
e
)
// XXX or we still want to log all errors - right?
}
//
log
.
Depth
(
1
)
.
Info
(
ctx
,
"]"
+
err
)
// XXX log -> trace, don't put ":" before "]"
// -> yes, we do want to trace unconditionally when a task is finished
// here it is tracing, just with trace sink being hardcoded to log.
// NOTE not *ctxp here - as context pointed by ctxp could be
log
.
Depth
(
1
)
.
Warning
(
ctx
,
"## "
,
*
errp
)
// XXX "##" temp
// changed when this deferred function is run
}
else
{
taskctx
.
ErrContext
(
errp
,
ctx
)
log
.
Depth
(
1
)
.
Info
(
ctx
,
"done"
)
}
}
// NOTE not *ctxp here - as context pointed by ctxp could be
// changed when this deferred function is run
taskctx
.
ErrContext
(
errp
,
ctx
)
}
}
}
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