Skip to main content

monolith-websocket-pubsub

Use when implementing real-time functionality using the built-in websocket pub/sub layer (`/ws`), including subscribe/message protocol and channel design.

معلومات المصدر

المستودع
cggonzal/monolith
آخر نشاط في المصدر
١٤ فبراير ٢٠٢٦ في ٠٣:١١
لغة SKILL.md المكتشفة
الإنجليزية
النجوم
٠
التفرعات
٠

خيارات التثبيت

يُحدَّد Prompt الذي يراجع المصدر أولًا بشكل افتراضي. يمكنك التبديل إلى أمر مباشر أو تنزيل نسخة محلية.

مراجعة ملفات المصدر

اقرأ SKILL.md وأي ملفات مرافقة يعرضها SkillsMP قبل أن تقرر التثبيت.

عرض SKILL.md

SKILL.md
تعليمات المصدر · معاينة للقراءة فقط
name
monolith-websocket-pubsub
description
Use when implementing real-time functionality using the built-in websocket pub/sub layer (`/ws`), including subscribe/message protocol and channel design.
# Monolith WebSocket Pub/Sub ## Use this skill when - Building chat/live updates. - Debugging channel subscriptions or message broadcast behavior. ## Entry points - Route: `GET /ws` in `app/routes/routes.go` - Implementation: `ws/ws.go` - Persistent message model: `app/models/ws.go` ## Client protocol Send JSON commands: - Subscribe: `{"command":"subscribe","identifier":"ChatChannel"}` - Publish: `{"command":"message","identifier":"ChatChannel","data":"Hello"}` ## Server behavior - Hub tracks channel subscriptions. - `message` commands are persisted then broadcast to subscribed clients. - Client loop handles register/unregister and ping/pong lifecycle. ## Extension workflow 1. Pick channel naming strategy (room, user, domain event). 2. Add frontend websocket client logic in `static/js/application.js` or app-specific JS. 3. Optionally enforce auth checks before allowing subscribe/publish. 4. Add tests in `ws/ws_test.go` style for command handling.
عرض على GitHub