Vote votes to set shard state and returns true if state was changed.
(up bool)
| 297 | |
| 298 | // Vote votes to set shard state and returns true if state was changed. |
| 299 | func (shard *ringShard) Vote(up bool) bool { |
| 300 | if up { |
| 301 | changed := shard.IsDown() |
| 302 | atomic.StoreInt32(&shard.down, 0) |
| 303 | return changed |
| 304 | } |
| 305 | |
| 306 | if shard.IsDown() { |
| 307 | return false |
| 308 | } |
| 309 | |
| 310 | atomic.AddInt32(&shard.down, 1) |
| 311 | return shard.IsDown() |
| 312 | } |
| 313 | |
| 314 | //------------------------------------------------------------------------------ |
| 315 |