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
c8565988
Commit
c8565988
authored
Feb 24, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b254a74d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
go/neo/xneo/statelog.go
go/neo/xneo/statelog.go
+19
-6
No files found.
go/neo/xneo/statelog.go
View file @
c8565988
...
...
@@ -20,20 +20,23 @@
package
xneo
// transactional log of states
//
XXX ..
.
//
State represents state of a cluster
.
type
State
struct
{
// XXX +transaction ID?
NodeTab
*
NodeTable
// nodes in the cluster
PartTab
*
PartitionTable
// on which nodes which data is located
ClusterState
proto
.
ClusterState
// code for cluster state
}
type
StateSnapshot
interface
{
NodeTab
()
RONodeTable
PartTab
()
ROPartitionTable
// StateRO provides read-only access to a State.
type
StateRO
interface
{
NodeTab
()
NodeTableRO
PartTab
()
PartitionTableRO
ClusterState
()
proto
.
ClusterState
}
//
XXX transactional journal ..
.
//
StateLog is transactional journal of State changes
.
type
StateLog
struct
{
mu
sync
.
Mutex
head
*
State
...
...
@@ -41,7 +44,7 @@ type StateLog struct {
// ReadHead returns state from head of the log.
func
(
l
*
StateLog
)
ReadHead
()
State
Snapshot
{
func
(
l
*
StateLog
)
ReadHead
()
State
RO
{
l
.
mu
.
Lock
()
defer
l
.
mu
.
Unlock
()
return
l
.
head
...
...
@@ -55,3 +58,13 @@ func (l *StateLog) CommitUpdate(δf func(*State)) {
δf
(
s
)
l
.
head
=
s
}
// Clone creates new instance of State initialized with previous content.
func
(
s
*
State
)
Clone
()
*
State
{
return
&
State
{
NodeTab
:
s
.
NodeTab
.
Clone
(),
PartTab
:
s
.
PartTab
.
Clone
(),
ClusterState
:
s
.
ClusterState
,
}
}
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