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
96580b58
Commit
96580b58
authored
Feb 19, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b211c7b2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
33 deletions
+42
-33
go/internal/xcontext/xcontext.go
go/internal/xcontext/xcontext.go
+3
-3
go/neo/cmd/neo/master.go
go/neo/cmd/neo/master.go
+16
-11
go/neo/cmd/neo/storage.go
go/neo/cmd/neo/storage.go
+23
-19
No files found.
go/internal/xcontext/xcontext.go
View file @
96580b58
...
...
@@ -81,7 +81,7 @@ func WhenDone(ctx context.Context, f func()) func() {
// WithCloseOnErrCancel closes c on ctx cancel while f is run, or if f returns with an error.
//
// It is usually handy to propagate cancellation to interrupt IO.
// It is usually handy to propagate cancellation to interrupt IO.
XXX when f creates/leaves link alive.
// XXX naming?
// XXX don't close on f return?
func
WithCloseOnErrCancel
(
ctx
context
.
Context
,
c
io
.
Closer
,
f
func
()
error
)
(
err
error
)
{
...
...
@@ -92,7 +92,7 @@ func WithCloseOnErrCancel(ctx context.Context, c io.Closer, f func() error) (err
if
err
!=
nil
{
if
!
closed
{
c
.
Close
()
c
.
Close
()
// XXX log err?
}
}
}()
...
...
@@ -107,7 +107,7 @@ func WithCloseOnErrCancel(ctx context.Context, c io.Closer, f func() error) (err
select
{
case
<-
ctx
.
Done
()
:
c
.
Close
()
// interrupt IO
c
.
Close
()
// interrupt IO
XXX log err?
closed
=
true
return
ctx
.
Err
()
...
...
go/neo/cmd/neo/master.go
View file @
96580b58
...
...
@@ -28,6 +28,7 @@ import (
"os"
"lab.nexedi.com/kirr/go123/prog"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/neo/go/neo"
)
...
...
@@ -49,7 +50,7 @@ func masterMain(argv []string) {
flags
.
Usage
=
func
()
{
masterUsage
(
os
.
Stderr
);
flags
.
PrintDefaults
()
}
netSetup
:=
netFlags
(
flags
)
cluster
:=
flags
.
String
(
"cluster"
,
""
,
"cluster name"
)
//
XXX masters here too
?
//
TODO masters here too (multiple masters)
?
bind
:=
flags
.
String
(
"bind"
,
""
,
"address to serve on"
)
flags
.
Parse
(
argv
[
1
:
])
...
...
@@ -64,17 +65,21 @@ func masterMain(argv []string) {
}
ctx
:=
context
.
Background
()
err
:=
func
()
(
err
error
)
{
net
,
err
:=
netSetup
(
ctx
)
if
err
!=
nil
{
return
err
}
defer
func
()
{
__
:=
net
.
Close
()
err
=
xerr
.
First
(
err
,
__
)
}()
net
,
err
:=
netSetup
(
ctx
)
if
err
!=
nil
{
prog
.
Fatal
(
err
)
}
defer
net
.
Close
()
// XXX err
err
=
listenAndServe
(
ctx
,
net
,
*
bind
,
func
(
ctx
context
.
Context
,
l
xnet
.
Listener
)
error
{
master
:=
neo
.
NewMaster
(
*
cluster
,
net
)
return
master
.
Run
(
ctx
,
l
)
})
return
listenAndServe
(
ctx
,
net
,
*
bind
,
func
(
ctx
context
.
Context
,
l
xnet
.
Listener
)
error
{
master
:=
neo
.
NewMaster
(
*
cluster
,
net
)
return
master
.
Run
(
ctx
,
l
)
})
}()
if
err
!=
nil
{
prog
.
Fatal
(
err
)
...
...
go/neo/cmd/neo/storage.go
View file @
96580b58
...
...
@@ -30,6 +30,7 @@ import (
"strings"
"lab.nexedi.com/kirr/go123/prog"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/neo/go/neo"
"lab.nexedi.com/kirr/neo/go/neo/storage"
...
...
@@ -79,7 +80,7 @@ func storageMain(argv []string) {
prog
.
Fatal
(
"master list must be provided"
)
}
if
len
(
masterv
)
>
1
{
prog
.
Fatal
(
"
BUG
neo/go POC currently supports only 1 master"
)
prog
.
Fatal
(
"
TODO
neo/go POC currently supports only 1 master"
)
}
master
:=
masterv
[
0
]
...
...
@@ -102,24 +103,27 @@ func storageMain(argv []string) {
runtime
.
GOMAXPROCS
(
maxprocs
*
8
)
// XXX *8 is enough?
ctx
:=
context
.
Background
()
back
,
err
:=
storage
.
OpenBackend
(
ctx
,
argv
[
0
])
if
err
!=
nil
{
prog
.
Fatal
(
err
)
}
net
,
err
:=
netSetup
(
ctx
)
if
err
!=
nil
{
prog
.
Fatal
(
err
)
}
defer
net
.
Close
()
// XXX err
err
=
listenAndServe
(
ctx
,
net
,
*
bind
,
func
(
ctx
context
.
Context
,
l
xnet
.
Listener
)
error
{
stor
:=
neo
.
NewStorage
(
*
cluster
,
master
,
net
,
back
)
return
stor
.
Run
(
ctx
,
l
)
})
// XXX back.Close here or in Storage?
err
:=
func
()
(
err
error
)
{
back
,
err
:=
storage
.
OpenBackend
(
ctx
,
argv
[
0
])
if
err
!=
nil
{
return
err
}
// XXX back.Close here or in Storage?
net
,
err
:=
netSetup
(
ctx
)
if
err
!=
nil
{
return
err
}
defer
func
()
{
__
:=
net
.
Close
()
err
=
xerr
.
First
(
err
,
__
)
}()
return
listenAndServe
(
ctx
,
net
,
*
bind
,
func
(
ctx
context
.
Context
,
l
xnet
.
Listener
)
error
{
stor
:=
neo
.
NewStorage
(
*
cluster
,
master
,
net
,
back
)
return
stor
.
Run
(
ctx
,
l
)
})
}()
if
err
!=
nil
{
prog
.
Fatal
(
err
)
...
...
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