Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
goSDN
Merge requests
!138
Develop
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Develop
develop
into
master
Overview
0
Commits
196
Pipelines
446
Changes
8
Closed
Ghost User
requested to merge
develop
into
master
4 years ago
Overview
0
Commits
196
Pipelines
446
Changes
8
Expand
0
0
Merge request reports
Viewing commit
7c2555fe
Show latest version
8 files
+
47
−
48
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
8
Search (e.g. *.vue) (Ctrl+P)
7c2555fe
linter pleasing
· 7c2555fe
Manuel Kieweg
authored
4 years ago
nucleus/pnd/change.go
+
9
−
0
Options
@@ -30,6 +30,10 @@ func init() {
log
.
Debugf
(
"change timeout set to %v"
,
changeTimeout
)
}
// NewChange takes a Device UUID, a pair GoStructs (current and intended state)
// a callback function and a channel for errors and returns a *Change
// The callback function is used by the Commit() and Confirm() functions. It
// must define how the change is carried out.
func
NewChange
(
device
uuid
.
UUID
,
currentState
ygot
.
GoStruct
,
change
ygot
.
GoStruct
,
callback
func
(
ygot
.
GoStruct
,
ygot
.
GoStruct
)
error
,
errChan
chan
error
)
*
Change
{
return
&
Change
{
cuid
:
uuid
.
New
(),
@@ -66,10 +70,14 @@ type Change struct {
Done
chan
int
}
// ID returns the Change's UUID
func
(
c
*
Change
)
ID
()
uuid
.
UUID
{
return
c
.
cuid
}
// Commit pushes the cange to the OND using the callback() function
// and starts the timeout-timer for the Change. If the timer expires
// the change is rolled back.
func
(
c
*
Change
)
Commit
()
error
{
if
err
:=
c
.
callback
(
c
.
intendedState
,
c
.
previousState
);
err
!=
nil
{
return
err
@@ -102,6 +110,7 @@ func (c *Change) rollbackHandler(ctx context.Context) {
}
}
// Confirm confirms a committed Change and stops the rollback timer.
func
(
c
*
Change
)
Confirm
()
error
{
c
.
lock
.
RLock
()
if
!
c
.
committed
{
Loading