[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"academy-blogs-th-1-1-all-websocket-microservices-go-all--*":3,"academy-blog-translations-8y1pu1r9wjxgave":115},{"data":4,"page":102,"perPage":102,"totalItems":102,"totalPages":102},[5],{"alt":6,"collectionId":7,"collectionName":8,"content":9,"cover_image":10,"cover_image_path":11,"created":12,"created_by":13,"expand":14,"id":110,"keywords":111,"locale":84,"published_at":112,"scheduled_at":13,"school_blog":106,"short_description":113,"status":104,"title":6,"updated":114,"updated_by":13,"slug":107,"views":109},"EP.32 การเชื่อมต่อ WebSocket กับ Microservices ใน Go เพื่อสร้างระบบที่ยืดหยุ่นและปรับขนาดได้","sclblg987654321","school_blog_translations","\u003Ch2>WebSocket กับ Microservices – การออกแบบระบบแบบกระจายตัวใน Go\u003C\u002Fh2>\u003Ch3>Microservices คืออะไร และทำไมต้องใช้ร่วมกับ WebSocket?\u003C\u002Fh3>\u003Cp>\u003Cstrong>Microservices\u003C\u002Fstrong> เป็นสถาปัตยกรรมที่ช่วยให้แอปพลิเคชันถูกแยกเป็นบริการย่อยๆ (Services) ซึ่งแต่ละบริการสามารถพัฒนาและขยายตัวได้อย่างอิสระ โดยเมื่อใช้งานร่วมกับ \u003Cstrong>WebSocket\u003C\u002Fstrong> ซึ่งเป็นโปรโตคอลที่ช่วยให้ระบบสามารถสื่อสารแบบเรียลไทม์ได้ ทำให้สามารถรองรับผู้ใช้งานจำนวนมากและทำงานได้อย่างมีประสิทธิภาพ\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch3>การสร้าง WebSocket Gateway\u003C\u002Fh3>\u003Cpre>\u003Ccode class=\"language-plaintext\">package main\n\nimport (\n    \"encoding\u002Fjson\"\n    \"log\"\n    \"net\u002Fhttp\"\n\n    \"github.com\u002Fgorilla\u002Fwebsocket\"\n)\n\nvar upgrader = websocket.Upgrader{\n    CheckOrigin: func(r *http.Request) bool {\n        return true\n    },\n}\n\ntype Event struct {\n    Service string      `json:\"service\"`\n    Action  string      `json:\"action\"`\n    Data    interface{} `json:\"data\"`\n}\n\nfunc handleConnections(w http.ResponseWriter, r *http.Request) {\n    conn, err := upgrader.Upgrade(w, r, nil)\n    if err != nil {\n        log.Println(\"Error upgrading connection:\", err)\n        return\n    }\n    defer conn.Close()\n\n    for {\n        _, msg, err := conn.ReadMessage()\n        if err != nil {\n            log.Println(\"Error reading message:\", err)\n            break\n        }\n\n        var event Event\n        if err := json.Unmarshal(msg, &amp;event); err != nil {\n            log.Println(\"Invalid event format:\", err)\n            continue\n        }\n    }\n}\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch4>ท้าให้ลอง!\u003C\u002Fh4>\u003Cp>ลองสร้างระบบแจ้งเตือนแบบเรียลไทม์ที่แยกเป็น Microservices โดยใช้ WebSocket Gateway และ Redis Pub\u002FSub เพื่อจัดการการแจ้งเตือนให้ผู้ใช้!\u003C\u002Fp>\u003Chr>\u003Ch4>EP ถัดไป\u003C\u002Fh4>\u003Cp>ใน \u003Cstrong>EP ถัดไป\u003C\u002Fstrong> เราจะพูดถึง \u003Cstrong>การใช้ GraphQL กับ WebSocket\u003C\u002Fstrong> เพื่อสร้าง API ที่ทรงพลังและรองรับการทำงานแบบเรียลไทม์!\u003C\u002Fp>","353lqnvabxpp_zqrwc825ow.webp","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclblg987654321\u002Fpwnam0fl1hwhxju\u002F353lqnvabxpp_zqrwc825ow.webp","2026-03-04 08:51:24.233Z","",{"keywords":15,"locale":78,"school_blog":88},[16,23,28,33,38,43,48,53,58,63,68,73],{"collectionId":17,"collectionName":18,"created":19,"created_by":13,"id":20,"name":21,"updated":22,"updated_by":13},"sclkey987654321","school_keywords","2026-03-04 08:51:22.473Z","xnw2u62a1h7c0ra","การออกแบบระบบ","2026-04-10 16:14:36.112Z",{"collectionId":17,"collectionName":18,"created":24,"created_by":13,"id":25,"name":26,"updated":27,"updated_by":13},"2026-03-04 08:44:49.445Z","0ips6v3gj6yy1h7","ระบบเรียลไทม์","2026-04-10 16:12:50.583Z",{"collectionId":17,"collectionName":18,"created":29,"created_by":13,"id":30,"name":31,"updated":32,"updated_by":13},"2026-03-04 08:34:10.254Z","rss87kgvhtvkri1","Redis Pub\u002FSub","2026-04-10 16:08:08.714Z",{"collectionId":17,"collectionName":18,"created":34,"created_by":13,"id":35,"name":36,"updated":37,"updated_by":13},"2026-03-04 08:51:21.416Z","t0608colrvvnvt5","API Gateway","2026-04-10 16:14:35.739Z",{"collectionId":17,"collectionName":18,"created":39,"created_by":13,"id":40,"name":41,"updated":42,"updated_by":13},"2026-03-04 08:51:21.627Z","lbet9y3a94m7s7o","gRPC","2026-04-10 16:14:35.846Z",{"collectionId":17,"collectionName":18,"created":44,"created_by":13,"id":45,"name":46,"updated":47,"updated_by":13},"2026-03-04 08:34:03.856Z","9dujh23qyko22y0","Load Balancing","2026-04-10 16:08:06.326Z",{"collectionId":17,"collectionName":18,"created":49,"created_by":13,"id":50,"name":51,"updated":52,"updated_by":13},"2026-03-04 08:44:30.561Z","mh6or11b3q7afdh","Microservices Architecture","2026-04-10 16:12:46.171Z",{"collectionId":17,"collectionName":18,"created":54,"created_by":13,"id":55,"name":56,"updated":57,"updated_by":13},"2026-03-04 08:51:21.925Z","qfrlqpe72r1b6yi","WebSocket Gateway","2026-04-10 16:14:36.027Z",{"collectionId":17,"collectionName":18,"created":59,"created_by":13,"id":60,"name":61,"updated":62,"updated_by":13},"2026-03-04 08:20:14.253Z","ah6lvy4x8qe08l5","Golang","2026-04-10 16:07:26.172Z",{"collectionId":17,"collectionName":18,"created":64,"created_by":13,"id":65,"name":66,"updated":67,"updated_by":13},"2026-03-04 08:20:11.547Z","ey3puyme01a9bsw","Go","2026-04-10 16:07:25.893Z",{"collectionId":17,"collectionName":18,"created":69,"created_by":13,"id":70,"name":71,"updated":72,"updated_by":13},"2026-03-04 08:44:29.876Z","ozn15duk6wovj6g","Microservices","2026-04-10 16:12:46.024Z",{"collectionId":17,"collectionName":18,"created":74,"created_by":13,"id":75,"name":76,"updated":77,"updated_by":13},"2026-03-04 08:34:00.920Z","ecac9y661or1xka","WebSocket","2026-04-10 16:08:05.227Z",{"code":79,"collectionId":80,"collectionName":81,"created":82,"flag":83,"id":84,"is_default":85,"label":86,"updated":87},"th","pbc_1989393366","locales","2026-01-22 10:59:55.832Z","twemoji:flag-thailand","s8wri3bt4vgg2ji",true,"Thai","2026-04-10 15:42:46.614Z",{"category":89,"collectionId":90,"collectionName":91,"created":13,"expand":92,"id":106,"slug":107,"updated":108,"views":109},"wqxt7ag2gn7xcmk","pbc_2105096300","school_blogs",{"category":93},{"blogIds":94,"collectionId":95,"collectionName":96,"created":97,"created_by":13,"id":89,"image":98,"image_alt":13,"image_path":99,"label":100,"name":101,"priority":102,"publish_at":103,"scheduled_at":13,"status":104,"updated":105,"updated_by":13},[],"sclcatblg987654321","school_category_blogs","2026-03-04 08:33:53.210Z","59ty92ns80w_15oc1implw.png","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclcatblg987654321\u002Fwqxt7ag2gn7xcmk\u002F59ty92ns80w_15oc1implw.png",{"en":101,"th":101},"Golang The Series",1,"2026-03-16 04:39:38.440Z","published","2026-04-25 02:32:15.470Z","8y1pu1r9wjxgave","websocket-microservices-go","2026-05-10 19:41:22.577Z",287,"pwnam0fl1hwhxju",[20,25,30,35,40,45,50,55,60,65,70,75],"2025-03-10 02:57:14.310Z","เรียนรู้วิธีเชื่อมต่อ WebSocket กับ Microservices ในภาษา Go เพื่อพัฒนาแอปพลิเคชันแบบกระจายตัว รองรับการทำงานขนาดใหญ่ และปรับขนาดได้อย่างมีประสิทธิภาพ","2026-04-22 07:11:46.917Z",{"th":107,"en":107}]