feat: complete grpcSample() orchestrator in main.go
This commit is contained in:
+11
-4
@@ -10,15 +10,22 @@ import (
|
|||||||
var port = ":8080"
|
var port = ":8080"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
// 1단계: JSON 파싱 예제 실행
|
||||||
jsonexample.JsonParsingExample()
|
jsonexample.JsonParsingExample()
|
||||||
|
|
||||||
|
// 3단계: gRPC 통신 예제 실행 (필요 시 주석 제거하여 활성화 가능)
|
||||||
|
// grpcSample()
|
||||||
}
|
}
|
||||||
|
|
||||||
func grpcSample() {
|
func grpcSample() {
|
||||||
|
fmt.Println("--- starting gRPC IoT Simulation ---")
|
||||||
|
|
||||||
|
// 1. gRPC 서버를 백그라운드 고루틴으로 구동
|
||||||
go entity.ServerRun(port)
|
go entity.ServerRun(port)
|
||||||
|
|
||||||
// Just to be sure that the server is running
|
// 2. 서버 포트가 바인딩되어 통신 대기 상태에 들어갈 시간을 일시적으로 보장
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
fmt.Println("Client:")
|
// 3. gRPC 클라이언트를 구동하여 원격 프로시저(RPC) 기동 시뮬레이션 집행
|
||||||
entity.ClientRun("localhost" + port)
|
entity.ClientRun(port)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user