-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
32 lines (29 loc) · 875 Bytes
/
main.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
package main
import (
"factory_pattern/ops"
"fmt"
)
func main() {
baseOps, err := ops.CreateOps(map[string]interface{}{
"OpsType": ops.BaseType,
"PostUrl": "http://ops.cloud.com/send_heartbeat",
})
if err != nil {
fmt.Println("create baseOps failed, err: ", err.Error())
return
}
baseOps.DoConfigUpload() // Output: BaseOps: DoConfigUpload
baseOps.DoUpdate() // Output: BaseOps: DoUpdate
baseOps.SendHeartbeat() // Output: BaseOps: Send heartbeat
specialOps, err := ops.CreateOps(map[string]interface{}{
"OpsType": ops.SpecialType,
"SendConfig": true,
})
if err != nil {
fmt.Println("create specialOps failed, err: ", err.Error())
return
}
specialOps.DoConfigUpload() // Output: SpecialOps: DoConfigUpload
specialOps.DoUpdate() // Output: BaseOps: DoUpdate
specialOps.SendHeartbeat() // Output: SpecialOps: SendHeartbeat
}