Parcourir la source

[refactor, feat] 모스카토 구조체 변경, 매칭 큐 추가

master
extra1563 il y a 4 ans
Parent
révision
2c6e33f05c
1 fichiers modifiés avec 13 ajouts et 19 suppressions
  1. 13
    19
      src/broker/modules/init.go

+ 13
- 19
src/broker/modules/init.go Voir le fichier

@@ -4,35 +4,29 @@ import (
4 4
 	"encoding/json"
5 5
 	"errors"
6 6
 	"fmt"
7
-	"github.com/fatih/color"
7
+	_ "github.com/fatih/color"
8 8
 	"log"
9 9
 	"net"
10 10
 	"net/rpc"
11 11
 )
12 12
 
13 13
 // TODO: RM 처리와 init.go 전반적으로 DI 이용하여 구현 RM 키등록 부분 구현 예정
14
-//temporary type for matching manager
15
-//type match_manager struct{}
16
-
17
-func (match_mng *match_manager) matching(queue *MsgQueue) {
18
-	//msg := queue.pop(true)
19
-	//Implement here ~~
20
-}
21
-
22
-func (match_mng *match_manager) add_subscription(msg MsgUnit) {
23
-
24
-}
25
-
26
-//temporary type for secure(key) manager
27
-type secure_manager struct{}
28 14
 
29 15
 type Moscato struct {
30 16
 	queue               MsgQueue
17
+	SendQueue			chan myType
31 18
 	MicroServiceManager NodeManager `inject:""`
32 19
 	MatchingManager     match_manager
20
+	Subscriptionmanager	sub_manager
33 21
 	SecureManager       SecurityManager `inject:""`
34 22
 }
35 23
 
24
+type myType struct{
25
+	subList	[]string
26
+	pubMsg	MsgUnit
27
+	err		error
28
+}
29
+
36 30
 type Reply struct {
37 31
 	CompleteLog string
38 32
 }
@@ -144,7 +138,7 @@ func (moscato *Moscato) Receive(msg MsgUnit) (MsgUnit, error) {
144 138
 		moscato.queue.push(msg.(PublishMsg))
145 139
 
146 140
 	case SM: //Subscription msg
147
-		moscato.MatchingManager.add_subscription(msg.(*SubscriptionMsg))
141
+		moscato.Subscriptionmanager.addSubscription(msg.(*SubscriptionMsg))
148 142
 
149 143
 	case RM: //Register msg
150 144
 		log.Println("RM received")
@@ -217,7 +211,7 @@ func (moscato *Moscato) Run() {
217 211
 	}
218 212
 
219 213
 	//go routine -> matching 동작
220
-	go moscato.MatchingManager.matching(&moscato.queue)
214
+	go moscato.Matching()
221 215
 	go moscato.CheckQueue()
222 216
 
223 217
 	//rpc 등록 -> Receive 함수
@@ -228,7 +222,7 @@ func (moscato *Moscato) Run() {
228 222
 	}
229 223
 
230 224
 	go Listen()
231
-	color.Blue("initializing complete.")
225
+	//color.Blue("initializing complete.")
232 226
 	fmt.Scanln()
233 227
 }
234 228
 
@@ -254,4 +248,4 @@ func Listen() {
254 248
 		conn, _ := l2.Accept()
255 249
 		go rpc.ServeConn(conn)
256 250
 	}*/
257
-}
251
+}

Chargement…
Annuler
Enregistrer