-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
77 lines (66 loc) · 2 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"Commondefs"
"EgressPipe"
"Mgmt"
"Rsrc"
"SshClient"
"TestInfra"
"fmt"
"time"
)
func main() {
// This will be used for sending reference of other package
// to required packages
var objPool []interface{}
rsc := Rsrc.Init()
// Create ssh client object
//sshclient := SshClient.Init()
sshclient := SshClient.Init()
objPool = append(objPool, rsc)
objPool = append(objPool, sshclient)
rsc.SetRefs(objPool)
// Run the Resource Go Routine
go rsc.ResourceRoutine()
// Create Ingress Channel
GlobalIngressCh := make(chan interface{})
// Create Mgmt Pipeline - User managerment, Resource Management etc
MgmtLeftCh, _ := Mgmt.CreateManagementPipeLine(GlobalIngressCh)
// THis Contains Basic Sanity, L2, L3, etcc
MgmtLeftCh, _ = TestInfra.CreateIngressTestPipeLine(MgmtLeftCh)
// THis pipeline decided on how many times, we have recycle the
// tests on failure etc
MgmtLeftCh, _ = EgressPipe.CreateEgressPipeLine(MgmtLeftCh)
// Data from Outside world is fed here to this Ingress Channel. Data can
// from Web server as HTTP Login Page Response
//req := &Commondefs.Request{User: &Commondefs.UserInfo{"Raju", "PRaju"}}
// Create Resource Object
time.Sleep(2 * time.Second)
rsc.FileReadCh <- struct{}{}
resp := &Commondefs.LoginResponse{}
go SendData(resp, GlobalIngressCh, MgmtLeftCh)
job := &Commondefs.UserJob{UserName: "Raju"}
go SendData(job, GlobalIngressCh, MgmtLeftCh)
time.Sleep(40 * time.Second)
// wait for ever
//select {}
}
func SendData(data interface{}, rightCh chan interface{}, leftCh chan interface{}) {
fmt.Println("SEnding Data onto Channel")
rightCh <- data
recvData := <-leftCh
DecodeReceivedData(recvData)
}
func DecodeReceivedData(data interface{}) {
switch data.(type) {
case *Commondefs.Request:
fmt.Println("Request Recevied")
case *Commondefs.LoginResponse:
fmt.Println("Login Reponse Recevied")
case *Commondefs.HttpUserResponse:
fmt.Println("Login Response Recevied")
default:
fmt.Println("UNDEFINED RESPONSE RECEIVED:")
}
return
}