-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improved failover for non-checkpointing scheduler
- Loading branch information
James DeFelice
committed
Apr 16, 2017
1 parent
c4a1026
commit eaeca69
Showing
10 changed files
with
167 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package app | ||
|
||
import "sync/atomic" | ||
|
||
// IDStore is a thread-safe abstraction to load and store a stringified ID. | ||
type IDStore interface { | ||
Get() string | ||
Set(string) | ||
} | ||
|
||
type IDStoreAdapter struct { | ||
GetFunc func() string | ||
SetFunc func(string) | ||
} | ||
|
||
func (a IDStoreAdapter) Get() string { | ||
if a.GetFunc != nil { | ||
return a.GetFunc() | ||
} | ||
return "" | ||
} | ||
|
||
func (a IDStoreAdapter) Set(s string) { | ||
if a.SetFunc != nil { | ||
a.SetFunc(s) | ||
} | ||
} | ||
|
||
func NewInMemoryIDStore() IDStore { | ||
var frameworkID atomic.Value | ||
return &IDStoreAdapter{ | ||
GetFunc: func() string { | ||
x := frameworkID.Load() | ||
if x == nil { | ||
return "" | ||
} | ||
return x.(string) | ||
}, | ||
SetFunc: func(s string) { | ||
frameworkID.Store(s) | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters