Browse Source

Timing info on queue/<q>

Frédéric G. MARAND 2 years ago
parent
commit
3616597626

+ 1 - 1
.run/Redriver.run.xml

@@ -2,7 +2,7 @@
   <configuration default="false" name="Redriver" type="GoApplicationRunConfiguration" factoryName="Go Application">
     <module name="sqs_demo" />
     <working_directory value="$PROJECT_DIR$" />
-    <parameters value="-profile=sqs-tutorial -addr :81 -wait 10" />
+    <parameters value="-profile=sqs-tutorial -addr :81 -wait 3" />
     <EXTENSION ID="net.ashald.envfile">
       <option name="IS_ENABLED" value="false" />
       <option name="IS_SUBST" value="false" />

+ 7 - 0
back/web/queue.go

@@ -23,22 +23,29 @@ func makeQueueHandler(rd redriver.Redriver) gin.HandlerFunc {
 		sess.AddFlash(fmt.Sprintf("Previous info acquired at: %v", time.Now()))
 		sess.Save()
 
+		t0 := time.Now()
 		qi, err := rd.GetQueueInfo(ctx, qName)
 		if err != nil {
 			log.Printf("failed getting info for queue %q: %v", qName, err)
 			c.JSON(http.StatusInternalServerError, nil)
 			return
 		}
+		infoLatency := time.Since(t0)
 		items, err := rd.GetQueueItems(ctx, qName)
 		if err != nil {
 			log.Printf("failed getting items for queue %q: %v", qName, err)
 			c.JSON(http.StatusInternalServerError, nil)
 			return
 		}
+		itemsLatency := time.Since(t0) - infoLatency
 		c.HTML(http.StatusOK, "", map[string]any{
 			"flashes": flashes,
 			"info":    qi,
 			"items":   items,
+			"latency": map[string]time.Duration{
+				"info":  infoLatency,
+				"items": itemsLatency,
+			},
 		})
 	}
 }

File diff suppressed because it is too large
+ 0 - 0
front/assets/bootstrap.css.map


File diff suppressed because it is too large
+ 427 - 0
front/assets/bootstrap.js


File diff suppressed because it is too large
+ 0 - 0
front/assets/bootstrap.js.map


File diff suppressed because it is too large
+ 3 - 2
front/assets/bootstrap.min.css


File diff suppressed because it is too large
+ 0 - 0
front/assets/bootstrap.min.css.map


File diff suppressed because it is too large
+ 5 - 0
front/assets/bootstrap.min.js


File diff suppressed because it is too large
+ 0 - 0
front/assets/bootstrap.min.js.map


+ 2 - 1
front/templates/flashes.gohtml

@@ -1,12 +1,13 @@
 {{ define "flashes" -}}
     {{ if . }}
-        <div class="d-flex align-items-center p-3 bg-warning bg-opacity-10 border border-warning rounded mb-4">
+        <div class="alert alert-secondary d-flex align-items-center p-3 bg-warning bg-opacity-10 border border-warning rounded mb-4 alert-dismissible fade show">
             <span id="warning-emj">⚠️</span>
             <ul class="m-0">
                 {{ range . }}
                     <li>{{ . }}</li>
                 {{ end }}
             </ul>
+            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
         </div>
     {{ end }}
 {{ end }}

+ 9 - 1
front/templates/queue.gohtml

@@ -9,7 +9,7 @@
     </head>
     <body>
     <main class="container">
-        <div class="container mt-5">
+            <div class="container mt-5">
             <nav aria-label="breadcrumb">
                 <ol class="breadcrumb">
                     <li class="breadcrumb-item"><a href="#">Home</a></li>
@@ -18,6 +18,13 @@
             </nav>
             <h1 class="text-3xl font-bold underline">Queue view for {{ .info.Name }}</h1>
             {{ template "flashes" .flashes }}
+            <div class="alert alert-secondary alert-dismissible fade show">
+                <ul>
+                    <li>Délai SQS info: {{ .latency.info }}</li>
+                    <li>Délai SQS messages: {{ .latency.items }}</li>
+                </ul>
+                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
+            </div>
             <table class="table">
                 <thead>
                 <tr>
@@ -82,6 +89,7 @@
             </form>
         </section>
     </main>
+    <script src="/assets/bootstrap.js"></script>
     <script src="/assets/script.js"></script>
     </body>
     </html>

Some files were not shown because too many files changed in this diff