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
d9882191
Commit
d9882191
authored
Feb 23, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b3e86791
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
5 deletions
+27
-5
go/neo/xneo/xneo.go
go/neo/xneo/xneo.go
+27
-5
No files found.
go/neo/xneo/xneo.go
View file @
d9882191
...
...
@@ -23,7 +23,7 @@ package xneo
//go:generate gotrace gen .
import
(
//
"sync"
"sync"
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/neo/go/neo/proto"
...
...
@@ -33,6 +33,7 @@ import (
//
// XXX text about imaginary transactional log of state changes originated from master.
// XXX naming: review (struct and field names)
type
State
=
NodeState
// XXX temp
type
NodeState
struct
{
MyNID
proto
.
NodeID
// nid received by node from M XXX -> MasteredState ? (because .mlink is there ?)
IdTime
proto
.
IdTime
// when this node last identified to master
...
...
@@ -110,8 +111,10 @@ type Node struct {
// MyInfo proto.NodeInfo // type, laddr, nid, state, idtime XXX nid is managed by M
Type
proto
.
NodeType
Addr
proto
.
Address
// listening address XXX -> LAddr ?
State
NodeState
// XXX type, laddr
stateLogMu
sync
.
Mutex
state
*
NodeState
ClusterName
string
Net
xnet
.
Networker
// network AP we are sending/receiving on
MasterAddr
string
// address of current master TODO -> masterRegistry
...
...
@@ -128,7 +131,7 @@ type Node struct {
func
NewNode
(
typ
proto
.
NodeType
,
clusterName
string
,
net
xnet
.
Networker
,
masterAddr
string
)
*
Node
{
node
:=
&
Node
{
Type
:
typ
,
State
:
NodeState
{
state
:
&
NodeState
{
MyNID
:
proto
.
NID
(
typ
,
0
),
// temp, e.g. S? TODO use "temp" bit in NodeID
IdTime
:
proto
.
IdTimeNone
,
...
...
@@ -143,6 +146,25 @@ func NewNode(typ proto.NodeType, clusterName string, net xnet.Networker, masterA
MasterAddr
:
masterAddr
,
}
node
.
S
tate
.
NodeTab
.
localNode
=
node
node
.
s
tate
.
NodeTab
.
localNode
=
node
return
node
}
// XXX doc, naming
func
(
node
*
Node
)
WithState
(
f
func
(
*
/*readonly*/
State
))
{
node
.
stateLogMu
.
Lock
()
s
:=
node
.
state
node
.
stateLogMu
.
Unlock
()
f
(
s
)
}
// XXX doc
func
(
node
*
Node
)
ModifyState
(
δf
func
(
*
State
))
{
node
.
stateLogMu
.
Lock
()
defer
node
.
stateLogMu
.
Unlock
()
s
:=
node
.
state
.
Clone
()
δf
(
s
)
node
.
state
=
s
}
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