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
9afb634d
Commit
9afb634d
authored
May 23, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
eb2becec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
25 deletions
+23
-25
go/neo/master.go
go/neo/master.go
+15
-19
go/neo/nodetab.go
go/neo/nodetab.go
+8
-6
No files found.
go/neo/master.go
View file @
9afb634d
...
...
@@ -139,12 +139,11 @@ func (m *Master) ServeLink(ctx context.Context, link *NodeLink) {
// subscribe to nodeTab/partTab/clusterState and notify peer with updates
m
.
stateMu
.
Lock
()
//clusterCh := make(chan ClusterState)
nodeCh
,
nodeUnsubscribe
:=
m
.
nodeTab
.
SubscribeBuffered
()
_
=
nodeCh
;
_
=
nodeUnsubscribe
//partCh, partUnsubscribe := m.partTab.SubscribeBuffered()
// TODO cluster subscribe
//clusterCh := make(chan ClusterState)
//m.clusterNotifyv = append(m.clusterNotifyv, clusterCh)
...
...
@@ -159,25 +158,22 @@ func (m *Master) ServeLink(ctx context.Context, link *NodeLink) {
// ClusterInformation (PM -> * ?)
m
.
stateMu
.
Unlock
()
/*
go
func
()
{
var updates []...
}()
go func() {
var clusterState ClusterState
changed := false
select {
case clusterState = <-clusterCh:
changed = true
for
{
select
{
case
<-
ctx
.
Done
()
:
// TODO unsubscribe
// XXX we are not draining on cancel - how to free internal buffer ?
return
case
nodeUpdateV
:=
<-
nodeCh
:
// TODO
case
clusterState
=
<-
clusterCh
:
changed
=
true
}
}
}()
*/
// identification passed, now serve other requests
...
...
go/neo/nodetab.go
View file @
9afb634d
...
...
@@ -88,7 +88,9 @@ type Node struct {
// Subscribe subscribes to NodeTable updates
// it returns a channel via which updates will be delivered
// it returns a channel via which updates will be delivered and unsubscribe function
//
// XXX locking: client for subscribe/unsubscribe XXX ok?
func
(
nt
*
NodeTable
)
Subscribe
()
(
ch
chan
*
Node
,
unsubscribe
func
())
{
ch
=
make
(
chan
*
Node
)
// XXX how to specify ch buf size if needed ?
nt
.
subscribev
=
append
(
nt
.
subscribev
,
ch
)
...
...
@@ -108,13 +110,13 @@ func (nt *NodeTable) Subscribe() (ch chan *Node, unsubscribe func()) {
}
// SubscribeBufferred subscribes to NodeTable updates without blocking updater
// it returns a channel via which updates are delivered
// the updates
are sent to destination in non-blocking way - if destination channel is not ready
// they will be bufferred.
// it returns a channel via which updates are delivered
and unsubscribe function
// the updates
will be sent to destination in non-blocking way - if destination
//
channel is not ready
they will be bufferred.
// it is the caller reponsibility to make sure such buffering does not grow up
// to infinity - via e.g. detecting stuck connections and unsubscribing on shutdown
//
//
must be called with stateMu held
//
XXX locking: client for subscribe/unsubscribe XXX ok?
func
(
nt
*
NodeTable
)
SubscribeBuffered
()
(
ch
chan
[]
*
Node
,
unsubscribe
func
())
{
in
,
unsubscribe
:=
nt
.
Subscribe
()
ch
=
make
(
chan
[]
*
Node
)
...
...
@@ -142,7 +144,7 @@ func (nt *NodeTable) SubscribeBuffered() (ch chan []*Node, unsubscribe func()) {
break
}
// FIXME
better merge
as same node could be updated several times
// FIXME
merge updates
as same node could be updated several times
updatev
=
append
(
updatev
,
update
)
case
out
<-
updatev
:
...
...
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