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
d77ccb51
Commit
d77ccb51
authored
Aug 10, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7fa264d5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
25 deletions
+93
-25
go/neo/server/master.go
go/neo/server/master.go
+2
-0
go/neo/server/util.go
go/neo/server/util.go
+21
-0
go/xcommon/log/log.go
go/xcommon/log/log.go
+53
-0
go/xcommon/task/task.go
go/xcommon/task/task.go
+17
-25
No files found.
go/neo/server/master.go
View file @
d77ccb51
...
@@ -258,6 +258,8 @@ type storRecovery struct {
...
@@ -258,6 +258,8 @@ type storRecovery struct {
// - nil: recovery was ok and a command came for cluster to start
// - nil: recovery was ok and a command came for cluster to start
// - !nil: recovery was cancelled
// - !nil: recovery was cancelled
func
(
m
*
Master
)
recovery
(
ctx
context
.
Context
)
(
err
error
)
{
func
(
m
*
Master
)
recovery
(
ctx
context
.
Context
)
(
err
error
)
{
defer
running
(
&
ctx
,
"recovery"
)(
&
err
)
ctx
=
task
.
Running
(
ctx
,
"recovery"
)
ctx
=
task
.
Running
(
ctx
,
"recovery"
)
defer
task
.
ErrContext
(
&
err
,
ctx
)
defer
task
.
ErrContext
(
&
err
,
ctx
)
log
.
Infof
(
ctx
,
""
)
// XXX automatically log in task.Running?
log
.
Infof
(
ctx
,
""
)
// XXX automatically log in task.Running?
...
...
go/neo/server/util.go
0 → 100644
View file @
d77ccb51
// Copyright (C) 2017 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package
server
// misc utilities
go/xcommon/log/log.go
0 → 100644
View file @
d77ccb51
// Copyright (C) 2017 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// Package log provides logging with severity levels and tasks integration
//
// XXX inspired by cockrach
package
log
import
(
"github.com/golang/glog"
"lab.nexedi.com/kirr/neo/go/xcommon/task"
)
// taskPrefix returns prefix associated to current operational task stack to put to logs
func
taskPrefix
(
ctx
)
string
{
s
:=
task
.
Current
(
ctx
)
.
String
()
if
s
!=
""
{
s
+=
": "
}
return
s
}
type
Depth
int
func
(
d
Depth
)
Infof
(
ctx
context
.
Context
,
format
string
,
argv
...
interface
{})
{
// XXX avoid formatting if logging severity disables info
glog
.
InfoDepth
(
d
+
1
,
taskPrefix
(
ctx
)
+
fmt
.
Sprintf
(
format
,
argv
)
}
func
Infof
(
ctx
context
.
Context
,
format
string
,
argv
...
interface
{})
{
Depth
(
1
)
.
Infof
(
ctx
,
format
,
argv
)
}
// TODO Warningf, Errorf, ...
go/xcommon/task/task.go
View file @
d77ccb51
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// See https://www.nexedi.com/licensing for rationale and options.
// Package task
allows to define currently running task via context XXX
// Package task
provides primitives to track tasks via contexts.
package
task
package
task
import
(
import
(
...
@@ -30,23 +30,6 @@ type Task struct {
...
@@ -30,23 +30,6 @@ type Task struct {
Name
string
Name
string
}
}
// String returns string representing whole operational stack.
//
// 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"
func
(
t
*
Task
)
String
()
string
{
if
o
==
nil
{
return
""
}
prefix
:=
Parent
.
String
()
if
prefix
!=
""
{
prefix
+=
": "
}
return
prefix
+
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
...
@@ -78,12 +61,21 @@ func ErrContext(errp *error, ctx Context) {
...
@@ -78,12 +61,21 @@ func ErrContext(errp *error, ctx Context) {
return
xerr
.
Context
(
errp
,
task
.
Name
)
return
xerr
.
Context
(
errp
,
task
.
Name
)
}
}
// XXX place
// String returns string representing whole operational stack.
func
Logf
(
ctx
context
.
Context
,
format
string
,
argv
...
interface
{})
{
//
s
:=
CurrentOp
(
ctx
)
.
String
()
// For example if task "c" is running under task "b" which in turn is running
if
s
!=
""
{
// under task "a" - the operational stack will be "a: b: c"
s
+=
": "
//
// nil Task is represented as ""
func
(
t
*
Task
)
String
()
string
{
if
o
==
nil
{
return
""
}
prefix
:=
Parent
.
String
()
if
prefix
!=
""
{
prefix
+=
": "
}
}
s
+=
fmt
.
Sprintf
(
format
,
argv
...
)
log
.
Log
(
s
)
return
prefix
+
t
.
Name
}
}
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