go-duck-cli 1.4.8 → 1.4.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generators/telemetry.js +3 -3
- package/package.json +1 -1
- package/templates/go/router.go.hbs +14 -14
package/generators/telemetry.js
CHANGED
|
@@ -130,7 +130,7 @@ type StatusStats struct {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
type AppMetrics struct {
|
|
133
|
-
|
|
133
|
+
mu sync.RWMutex
|
|
134
134
|
StartTime time.Time
|
|
135
135
|
Endpoints map[string]*EndpointStats
|
|
136
136
|
StatusCodes map[int]*StatusStats
|
|
@@ -157,8 +157,8 @@ func MetricsTrackingMiddleware(cfg *config.Config) gin.HandlerFunc {
|
|
|
157
157
|
}
|
|
158
158
|
endpointKey := method + " " + path
|
|
159
159
|
|
|
160
|
-
globalMetrics.
|
|
161
|
-
defer globalMetrics.
|
|
160
|
+
globalMetrics.mu.Lock()
|
|
161
|
+
defer globalMetrics.mu.Unlock()
|
|
162
162
|
|
|
163
163
|
// Status Code tracking
|
|
164
164
|
if _, exists := globalMetrics.StatusCodes[status]; !exists {
|
package/package.json
CHANGED
|
@@ -185,8 +185,8 @@ func SetupRouter(appConfig *config.Config) *gin.Engine {
|
|
|
185
185
|
sysMetrics := telemetry.CollectSystemMetrics()
|
|
186
186
|
appMetrics := telemetry.GetGlobalMetrics()
|
|
187
187
|
|
|
188
|
-
appMetrics.
|
|
189
|
-
defer appMetrics.
|
|
188
|
+
appMetrics.mu.RLock()
|
|
189
|
+
defer appMetrics.mu.RUnlock()
|
|
190
190
|
|
|
191
191
|
c.JSON(http.StatusOK, gin.H{
|
|
192
192
|
"system": sysMetrics,
|
|
@@ -831,7 +831,7 @@ func SetupRouter(appConfig *config.Config) *gin.Engine {
|
|
|
831
831
|
} else {
|
|
832
832
|
viewSub.style.display = 'block';
|
|
833
833
|
viewPub.style.display = 'none';
|
|
834
|
-
mqttConsole.innerHTML =
|
|
834
|
+
mqttConsole.innerHTML = `Waiting for messages on ${topic}...\\n`;
|
|
835
835
|
}
|
|
836
836
|
|
|
837
837
|
actionModal.style.display = 'flex';
|
|
@@ -918,12 +918,12 @@ func SetupRouter(appConfig *config.Config) *gin.Engine {
|
|
|
918
918
|
tbody.innerHTML = '<tr><td colspan="4" style="text-align: center; color: #888;">No data available</td></tr>';
|
|
919
919
|
} else {
|
|
920
920
|
endpoints.forEach(([path, stats]) => {
|
|
921
|
-
tbody.innerHTML +=
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
921
|
+
tbody.innerHTML += `<tr>
|
|
922
|
+
<td style="font-family: monospace; font-weight: bold;">${path}</td>
|
|
923
|
+
<td>${stats.count}</td>
|
|
924
|
+
<td>${stats.mean_time_ms.toFixed(2)} ms</td>
|
|
925
|
+
<td>${stats.max_time_ms.toFixed(2)} ms</td>
|
|
926
|
+
</tr>`;
|
|
927
927
|
});
|
|
928
928
|
}
|
|
929
929
|
|
|
@@ -993,7 +993,7 @@ func SetupRouter(appConfig *config.Config) *gin.Engine {
|
|
|
993
993
|
brokerStatus.style.color = "#2ecc71";
|
|
994
994
|
if (actionTitle.innerText === 'SUBSCRIBE') {
|
|
995
995
|
mqttClient.subscribe(currentTopic, (err) => {
|
|
996
|
-
if(!err) mqttConsole.innerHTML +=
|
|
996
|
+
if(!err) mqttConsole.innerHTML += `Subscribed to ${currentTopic}\\n`;
|
|
997
997
|
});
|
|
998
998
|
}
|
|
999
999
|
});
|
|
@@ -1003,7 +1003,7 @@ func SetupRouter(appConfig *config.Config) *gin.Engine {
|
|
|
1003
1003
|
const time = new Date().toLocaleTimeString();
|
|
1004
1004
|
let msgStr = message.toString();
|
|
1005
1005
|
try { msgStr = JSON.stringify(JSON.parse(msgStr), null, 2); } catch(e){}
|
|
1006
|
-
mqttConsole.innerHTML +=
|
|
1006
|
+
mqttConsole.innerHTML += `\\n<span style="color:#888">[${time}]</span>\\n${msgStr}\\n`;
|
|
1007
1007
|
mqttConsole.scrollTop = mqttConsole.scrollHeight;
|
|
1008
1008
|
}
|
|
1009
1009
|
});
|
|
@@ -1053,16 +1053,16 @@ func SetupRouter(appConfig *config.Config) *gin.Engine {
|
|
|
1053
1053
|
.replace(/([{}[\]:,])/g, '<span class="syntax-punct">$1</span>');
|
|
1054
1054
|
|
|
1055
1055
|
// Inject buttons next to topics (Only if authenticated)
|
|
1056
|
-
highlighted = highlighted.replace(/"([^"]+)"(<span class="syntax-punct"
|
|
1056
|
+
highlighted = highlighted.replace(/"([^"]+)"(<span class="syntax-punct">.*?<\\/span>)/g, (match, topic, punct) => {
|
|
1057
1057
|
if (topic.includes('/')) {
|
|
1058
1058
|
let btnHtml = "";
|
|
1059
1059
|
if (keycloak && keycloak.authenticated) {
|
|
1060
1060
|
const isSend = /patch|put|post|create|update/i.test(topic);
|
|
1061
1061
|
const btnLabel = isSend ? "SEND" : "SUBSCRIBE";
|
|
1062
1062
|
const btnColor = isSend ? "#e74c3c" : "#3498db";
|
|
1063
|
-
btnHtml =
|
|
1063
|
+
btnHtml = ` <button class="mqtt-action-btn" style="background:${btnColor}" onclick="openMqttAction('${topic}', '${btnLabel}')">${btnLabel}</button>`;
|
|
1064
1064
|
}
|
|
1065
|
-
return
|
|
1065
|
+
return `"${topic}"${punct}${btnHtml}`;
|
|
1066
1066
|
}
|
|
1067
1067
|
return match;
|
|
1068
1068
|
});
|