-
Notifications
You must be signed in to change notification settings - Fork 115
/
configure_networks.go
53 lines (41 loc) · 1.32 KB
/
configure_networks.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
44
45
46
47
48
49
50
51
52
53
package action
import (
"errors"
"time"
)
type ConfigureNetworksAction struct {
waitToKillAgentInterval time.Duration
agentKiller Killer
}
func NewConfigureNetworks(agentKiller Killer) (prepareAction ConfigureNetworksAction) {
prepareAction.waitToKillAgentInterval = 1 * time.Second
prepareAction.agentKiller = agentKiller
return
}
func (a ConfigureNetworksAction) IsAsynchronous(_ ProtocolVersion) bool {
return true
}
func (a ConfigureNetworksAction) IsPersistent() bool {
return true
}
func (a ConfigureNetworksAction) IsLoggable() bool {
return true
}
func (a ConfigureNetworksAction) Run() (interface{}, error) {
// Two possible ways to implement this action:
// (1) Restart agent which will in turn fetch infrastructure settings
// (2) Re-fetch infrastructure settings yourself, and reinitialize connections
//
// Option 1 was picked for simplicity and
// to avoid having two ways to reload connections.
// Instead of waiting for some time, ideally this action would receive a signal
// that asynchronous task response was sent to the API consumer.
go a.agentKiller.KillAgent(a.waitToKillAgentInterval)
panic("unreachable")
}
func (a ConfigureNetworksAction) Resume() (interface{}, error) {
return "ok", nil
}
func (a ConfigureNetworksAction) Cancel() error {
return errors.New("not supported")
}