-
Notifications
You must be signed in to change notification settings - Fork 6
/
actor_sync_update.go
43 lines (37 loc) · 981 Bytes
/
actor_sync_update.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package object
import (
"context"
"github.com/opensvc/om3/core/actioncontext"
"github.com/opensvc/om3/core/resource"
)
// SyncUpdate does an immediate data synchronization to target nodes.
func (t *actor) SyncUpdate(ctx context.Context) error {
ctx = actioncontext.WithProps(ctx, actioncontext.SyncUpdate)
if err := t.validateAction(); err != nil {
return err
}
t.setenv("sync_update", false)
unlock, err := t.lockAction(ctx)
if err != nil {
return err
}
defer unlock()
return t.lockedSyncUpdate(ctx)
}
func (t *actor) lockedSyncUpdate(ctx context.Context) error {
if err := t.masterSyncUpdate(ctx); err != nil {
return err
}
if err := t.slaveSyncUpdate(ctx); err != nil {
return err
}
return nil
}
func (t *actor) masterSyncUpdate(ctx context.Context) error {
return t.action(ctx, func(ctx context.Context, r resource.Driver) error {
return resource.Update(ctx, r)
})
}
func (t *actor) slaveSyncUpdate(ctx context.Context) error {
return nil
}